aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/env/delete_spec.rb
blob: 1e677fb2523b3639489bc7916f216a19a2fc771d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require_relative '../../spec_helper'

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