diff --git a/core/thread/thread_variable_get_spec.rb b/core/thread/thread_variable_get_spec.rb index 2eff1686f..67017771f 100644 --- a/core/thread/thread_variable_get_spec.rb +++ b/core/thread/thread_variable_get_spec.rb @@ -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 diff --git a/core/thread/thread_variable_set_spec.rb b/core/thread/thread_variable_set_spec.rb index f8f790dc0..c262a6614 100644 --- a/core/thread/thread_variable_set_spec.rb +++ b/core/thread/thread_variable_set_spec.rb @@ -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 diff --git a/core/thread/thread_variable_spec.rb b/core/thread/thread_variable_spec.rb index 041c9f438..d64e6ec63 100644 --- a/core/thread/thread_variable_spec.rb +++ b/core/thread/thread_variable_spec.rb @@ -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 diff --git a/core/thread/thread_variables_spec.rb b/core/thread/thread_variables_spec.rb index 1c4937208..51ceef337 100644 --- a/core/thread/thread_variables_spec.rb +++ b/core/thread/thread_variables_spec.rb @@ -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