aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/env/element_reference_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/env/element_reference_spec.rb')
-rw-r--r--spec/ruby/core/env/element_reference_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/ruby/core/env/element_reference_spec.rb b/spec/ruby/core/env/element_reference_spec.rb
index 59b53fc4b1..7d2a2d78e3 100644
--- a/spec/ruby/core/env/element_reference_spec.rb
+++ b/spec/ruby/core/env/element_reference_spec.rb
@@ -19,6 +19,17 @@ describe "ENV.[]" do
ENV[@variable].frozen?.should == true
end
+ it "coerces a non-string name with #to_str" do
+ ENV[@variable] = "bar"
+ k = mock('key')
+ k.should_receive(:to_str).and_return(@variable)
+ ENV[k].should == "bar"
+ end
+
+ it "raises TypeError if the argument is not a String and does not respond to #to_str" do
+ -> { ENV[Object.new] }.should raise_error(TypeError, "no implicit conversion of Object into String")
+ end
+
platform_is :windows do
it "looks up values case-insensitively" do
ENV[@variable] = "bar"