1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2019-10-26 20:53:01 +02:00
parent 3eb0d50c0b
commit 664e96b1de
42 changed files with 484 additions and 117 deletions

View file

@ -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