diff options
author | Benoit Daloze <eregontp@gmail.com> | 2019-10-26 20:53:01 +0200 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-10-26 20:53:01 +0200 |
commit | 664e96b1de816c813c29f61e16a2031a7af7ba86 (patch) | |
tree | 7f4691847cd6b3282812eea7e2be3758e08d1433 /spec/ruby/core/env/delete_spec.rb | |
parent | 3eb0d50c0baae916f4486c264605b18e77bee0dc (diff) | |
download | ruby-664e96b1de816c813c29f61e16a2031a7af7ba86.tar.gz |
Update to ruby/spec@28a728b
Diffstat (limited to 'spec/ruby/core/env/delete_spec.rb')
-rw-r--r-- | spec/ruby/core/env/delete_spec.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/spec/ruby/core/env/delete_spec.rb b/spec/ruby/core/env/delete_spec.rb index 1e677fb252..e875df4aeb 100644 --- a/spec/ruby/core/env/delete_spec.rb +++ b/spec/ruby/core/env/delete_spec.rb @@ -1,8 +1,11 @@ require_relative '../../spec_helper' describe "ENV.delete" do + before :each do + @saved_foo = ENV["foo"] + end after :each do - ENV.delete("foo") + ENV["foo"] = @saved_foo end it "removes the variable from the environment" do @@ -16,9 +19,18 @@ describe "ENV.delete" do ENV.delete("foo").should == "bar" end + it "returns nil if the named environment variable does not exist and no block given" do + ENV.delete("foo") + ENV.delete("foo").should == nil + end + it "yields the name to the given block if the named environment variable does not exist" do ENV.delete("foo") ENV.delete("foo") { |name| ScratchPad.record name } ScratchPad.recorded.should == "foo" end + + it "raises TypeError if the argument is not a String and does not respond to #to_str" do + -> { ENV.delete(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String") + end end |