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/reject_spec.rb | |
parent | 3eb0d50c0baae916f4486c264605b18e77bee0dc (diff) | |
download | ruby-664e96b1de816c813c29f61e16a2031a7af7ba86.tar.gz |
Update to ruby/spec@28a728b
Diffstat (limited to 'spec/ruby/core/env/reject_spec.rb')
-rw-r--r-- | spec/ruby/core/env/reject_spec.rb | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/spec/ruby/core/env/reject_spec.rb b/spec/ruby/core/env/reject_spec.rb index 1026c2f451..6a9794925d 100644 --- a/spec/ruby/core/env/reject_spec.rb +++ b/spec/ruby/core/env/reject_spec.rb @@ -2,6 +2,14 @@ require_relative '../../spec_helper' require_relative '../enumerable/shared/enumeratorized' describe "ENV.reject!" do + before :each do + @foo = ENV["foo"] + end + + after :each do + ENV["foo"] = @foo + end + it "rejects entries based on key" do ENV["foo"] = "bar" ENV.reject! { |k, v| k == "foo" } @@ -17,12 +25,16 @@ describe "ENV.reject!" do it "returns itself or nil" do ENV.reject! { false }.should == nil ENV["foo"] = "bar" - ENV.reject! { |k, v| k == "foo" }.should == ENV + ENV.reject! { |k, v| k == "foo" }.should equal(ENV) ENV["foo"].should == nil end it "returns an Enumerator if called without a block" do - ENV.reject!.should be_an_instance_of(Enumerator) + ENV["foo"] = "bar" + enum = ENV.reject! + enum.should be_an_instance_of(Enumerator) + enum.each { |k, v| k == "foo" }.should equal(ENV) + ENV["foo"].should == nil end it "doesn't raise if empty" do @@ -39,6 +51,14 @@ describe "ENV.reject!" do end describe "ENV.reject" do + before :each do + @foo = ENV["foo"] + end + + after :each do + ENV["foo"] = @foo + end + it "rejects entries based on key" do ENV["foo"] = "bar" e = ENV.reject { |k, v| k == "foo" } @@ -60,7 +80,11 @@ describe "ENV.reject" do end it "returns an Enumerator if called without a block" do - ENV.reject.should be_an_instance_of(Enumerator) + ENV["foo"] = "bar" + enum = ENV.reject + enum.should be_an_instance_of(Enumerator) + enum.each { |k, v| k == "foo"} + ENV["foo"] = nil end it "doesn't raise if empty" do |