2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
describe "ENV.delete" do
|
|
|
|
after :each do
|
|
|
|
ENV.delete("foo")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "removes the variable from the environment" do
|
|
|
|
ENV["foo"] = "bar"
|
|
|
|
ENV.delete("foo")
|
|
|
|
ENV["foo"].should == nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns the previous value" do
|
|
|
|
ENV["foo"] = "bar"
|
|
|
|
ENV.delete("foo").should == "bar"
|
|
|
|
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
|
|
|
|
end
|