Skip to content

Commit

Permalink
Reword Thread #thread_variable_get/#thread_variable_set/#thread_varia…
Browse files Browse the repository at this point in the history
…ble?/#thread_variables specs titles
  • Loading branch information
andrykonchin committed Jun 26, 2024
1 parent 4cd2a60 commit 89328e4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
7 changes: 4 additions & 3 deletions core/thread/thread_variable_get_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
Thread.current.thread_variable_get(:thread_variable_get_spec).should be_nil
end

it "converts a String key into a Symbol" do
@t.thread_variable_set(:a, 49)
@t.thread_variable_get('a').should == 49
it "accepts String and Symbol keys interchangeably" do
@t.thread_variable_set("a", 49)
@t.thread_variable_get("a").should == 49
@t.thread_variable_get(:a).should == 49
end

it "converts a key that is neither String nor Symbol with #to_str" do
Expand Down
7 changes: 5 additions & 2 deletions core/thread/thread_variable_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
Thread.current.thread_variable_get(:thread_variable_get_spec).should be_nil
end

it "converts a String key into a Symbol" do
it "accepts String and Symbol keys interchangeably" do
@t.thread_variable_set('a', 49)
@t.thread_variable_get(:a).should == 49
@t.thread_variable_get('a').should == 49

@t.thread_variable_set(:a, 50)
@t.thread_variable_get('a').should == 50
end

it "converts a key that is neither String nor Symbol with #to_str" do
Expand Down
7 changes: 6 additions & 1 deletion core/thread/thread_variable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
@t.thread_variable?(:a).should be_true
end

it "converts a String key into a Symbol" do
it "accepts String and Symbol keys interchangeably" do
@t.thread_variable?('a').should be_false
@t.thread_variable?(:a).should be_false

@t.thread_variable_set(:a, 49)

@t.thread_variable?('a').should be_true
@t.thread_variable?(:a).should be_true
end

it "converts a key that is neither String nor Symbol with #to_str" do
Expand Down
6 changes: 4 additions & 2 deletions core/thread/thread_variables_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
@t.thread_variables.should == []
end

it "converts keys into Symbols" do
it "returns keys as Symbols" do
key = mock('key')
key.should_receive(:to_str).and_return('a')

@t.thread_variable_set(key, 49)
@t.thread_variable_set('b', 50)
@t.thread_variables.sort.should == [:a, :b]
@t.thread_variable_set(:c, 51)
@t.thread_variables.sort.should == [:a, :b, :c]
end
end

0 comments on commit 89328e4

Please sign in to comment.