summaryrefslogtreecommitdiff
path: root/spec/ruby/core/thread/element_reference_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/thread/element_reference_spec.rb')
-rw-r--r--spec/ruby/core/thread/element_reference_spec.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/spec/ruby/core/thread/element_reference_spec.rb b/spec/ruby/core/thread/element_reference_spec.rb
index 4de33e1456..fde9d1f440 100644
--- a/spec/ruby/core/thread/element_reference_spec.rb
+++ b/spec/ruby/core/thread/element_reference_spec.rb
@@ -37,8 +37,19 @@ describe "Thread#[]" do
t2["value"].should == 2
end
+ it "converts a key that is neither String nor Symbol with #to_str" do
+ key = mock('value')
+ key.should_receive(:to_str).and_return('value')
+
+ th = Thread.new do
+ Thread.current[:value] = 1
+ end.join
+
+ th[key].should == 1
+ end
+
it "raises exceptions on the wrong type of keys" do
- lambda { Thread.current[nil] }.should raise_error(TypeError)
- lambda { Thread.current[5] }.should raise_error(TypeError)
+ -> { Thread.current[nil] }.should raise_error(TypeError)
+ -> { Thread.current[5] }.should raise_error(TypeError)
end
end