diff options
Diffstat (limited to 'spec/ruby/core/env/shared/store.rb')
| -rw-r--r-- | spec/ruby/core/env/shared/store.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/spec/ruby/core/env/shared/store.rb b/spec/ruby/core/env/shared/store.rb index 4949ca8c73..388208a8ac 100644 --- a/spec/ruby/core/env/shared/store.rb +++ b/spec/ruby/core/env/shared/store.rb @@ -1,6 +1,10 @@ describe :env_store, shared: true do + before :each do + @saved_foo = ENV["foo"] + end + after :each do - ENV.delete("foo") + ENV["foo"] = @saved_foo end it "sets the environment variable to the given value" do @@ -10,13 +14,13 @@ describe :env_store, shared: true do it "returns the value" do value = "bar" - ENV.send(@method, "foo", value).should equal(value) + ENV.send(@method, "foo", value).should.equal?(value) end it "deletes the environment variable when the value is nil" do ENV["foo"] = "bar" ENV.send(@method, "foo", nil) - ENV.key?("foo").should be_false + ENV.key?("foo").should == false end it "coerces the key argument with #to_str" do @@ -34,23 +38,23 @@ describe :env_store, shared: true do end it "raises TypeError when the key is not coercible to String" do - lambda { ENV.send(@method, Object.new, "bar") }.should raise_error(TypeError) + -> { ENV.send(@method, Object.new, "bar") }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises TypeError when the value is not coercible to String" do - lambda { ENV.send(@method, "foo", Object.new) }.should raise_error(TypeError) + -> { ENV.send(@method, "foo", Object.new) }.should.raise(TypeError, "no implicit conversion of Object into String") end it "raises Errno::EINVAL when the key contains the '=' character" do - lambda { ENV.send(@method, "foo=", "bar") }.should raise_error(Errno::EINVAL) + -> { ENV.send(@method, "foo=", "bar") }.should.raise(Errno::EINVAL) end it "raises Errno::EINVAL when the key is an empty string" do - lambda { ENV.send(@method, "", "bar") }.should raise_error(Errno::EINVAL) + -> { ENV.send(@method, "", "bar") }.should.raise(Errno::EINVAL) end it "does nothing when the key is not a valid environment variable key and the value is nil" do ENV.send(@method, "foo=", nil) - ENV.key?("foo=").should be_false + ENV.key?("foo=").should == false end end |
