diff options
Diffstat (limited to 'spec/ruby/core/env/shared/to_hash.rb')
| -rw-r--r-- | spec/ruby/core/env/shared/to_hash.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/ruby/core/env/shared/to_hash.rb b/spec/ruby/core/env/shared/to_hash.rb new file mode 100644 index 0000000000..7868690c38 --- /dev/null +++ b/spec/ruby/core/env/shared/to_hash.rb @@ -0,0 +1,33 @@ +describe :env_to_hash, shared: true do + before :each do + @saved_foo = ENV["foo"] + end + + after :each do + ENV["foo"]= @saved_foo + end + + it "returns the ENV as a hash" do + ENV["foo"] = "bar" + h = ENV.send(@method) + h.should.instance_of?(Hash) + h["foo"].should == "bar" + end + + it "uses the locale encoding for keys" do + ENV.send(@method).keys.each {|k| k.should.be_locale_env } + end + + it "uses the locale encoding for values" do + ENV.send(@method).values.each {|k| k.should.be_locale_env } + end + + it "duplicates the ENV when converting to a Hash" do + h = ENV.send(@method) + h.should_not.equal? ENV + h.size.should == ENV.size + h.each_pair do |k, v| + ENV[k].should == v + end + end +end |
