diff options
Diffstat (limited to 'spec/ruby/core/env/shared/to_hash.rb')
| -rw-r--r-- | spec/ruby/core/env/shared/to_hash.rb | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/spec/ruby/core/env/shared/to_hash.rb b/spec/ruby/core/env/shared/to_hash.rb index 3bfbc415f7..7868690c38 100644 --- a/spec/ruby/core/env/shared/to_hash.rb +++ b/spec/ruby/core/env/shared/to_hash.rb @@ -1,22 +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 be_an_instance_of(Hash) + h.should.instance_of?(Hash) h["foo"].should == "bar" - ENV.delete "foo" end it "uses the locale encoding for keys" do - ENV.send(@method).keys.all? {|k| k.encoding == Encoding.find('locale') }.should be_true + ENV.send(@method).keys.each {|k| k.should.be_locale_env } end it "uses the locale encoding for values" do - ENV.send(@method).values.all? {|v| v.encoding == Encoding.find('locale') }.should be_true + 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.object_id.should_not == ENV.object_id + h.should_not.equal? ENV + h.size.should == ENV.size + h.each_pair do |k, v| + ENV[k].should == v + end end end |
