diff options
author | Kenichi Kamiya <kachick1@gmail.com> | 2019-06-21 12:28:28 +0900 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2019-06-21 18:25:01 +0200 |
commit | d01fd821875b989affc36e54e98f5dd67f47062e (patch) | |
tree | e34d7777ea878d7a5cc78d3429b3014dcccdf937 /spec/ruby | |
parent | 3b2d11ad90fcb64b41acc9006dfd1e40b4bd9000 (diff) | |
download | ruby-d01fd821875b989affc36e54e98f5dd67f47062e.tar.gz |
Alias ENV.merge! as ENV.update
[Feature #15947]
Closes: https://github.com/ruby/ruby/pull/2246
Diffstat (limited to 'spec/ruby')
-rw-r--r-- | spec/ruby/core/env/merge_spec.rb | 8 | ||||
-rw-r--r-- | spec/ruby/core/env/shared/update.rb | 21 | ||||
-rw-r--r-- | spec/ruby/core/env/update_spec.rb | 23 |
3 files changed, 31 insertions, 21 deletions
diff --git a/spec/ruby/core/env/merge_spec.rb b/spec/ruby/core/env/merge_spec.rb new file mode 100644 index 0000000000..b418cd11f4 --- /dev/null +++ b/spec/ruby/core/env/merge_spec.rb @@ -0,0 +1,8 @@ +require_relative '../../spec_helper' +require_relative 'shared/update' + +ruby_version_is "2.7" do + describe "ENV.merge!" do + it_behaves_like :env_update, :merge! + end +end diff --git a/spec/ruby/core/env/shared/update.rb b/spec/ruby/core/env/shared/update.rb new file mode 100644 index 0000000000..cd09877243 --- /dev/null +++ b/spec/ruby/core/env/shared/update.rb @@ -0,0 +1,21 @@ +describe :env_update, shared: true do + it "adds the parameter hash to ENV" do + ENV["foo"].should == nil + ENV.send @method, "foo" => "bar" + ENV["foo"].should == "bar" + ENV.delete "foo" + end + + it "yields key, the old value and the new value when replacing entries" do + ENV.send @method, "foo" => "bar" + ENV["foo"].should == "bar" + ENV.send(@method, "foo" => "boo") do |key, old, new| + key.should == "foo" + old.should == "bar" + new.should == "boo" + "rab" + end + ENV["foo"].should == "rab" + ENV.delete "foo" + end +end diff --git a/spec/ruby/core/env/update_spec.rb b/spec/ruby/core/env/update_spec.rb index 9f8775138a..95a8a2eb49 100644 --- a/spec/ruby/core/env/update_spec.rb +++ b/spec/ruby/core/env/update_spec.rb @@ -1,25 +1,6 @@ require_relative '../../spec_helper' +require_relative 'shared/update' describe "ENV.update" do - - it "adds the parameter hash to ENV" do - ENV["foo"].should == nil - ENV.update "foo" => "bar" - ENV["foo"].should == "bar" - ENV.delete "foo" - end - - it "yields key, the old value and the new value when replacing entries" do - ENV.update "foo" => "bar" - ENV["foo"].should == "bar" - ENV.update("foo" => "boo") do |key, old, new| - key.should == "foo" - old.should == "bar" - new.should == "boo" - "rab" - end - ENV["foo"].should == "rab" - ENV.delete "foo" - end - + it_behaves_like :env_update, :update end |