aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/build_environment_spec.rb
blob: 5a3cec45275021eb80a02b35cdc7929d57e92f23 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require "build_environment"

RSpec::Matchers.alias_matcher :use_userpaths, :be_userpaths

describe BuildEnvironment do
  let(:env) { described_class.new }

  describe "#<<" do
    it "returns itself" do
      expect(env << :foo).to be env
    end
  end

  describe "#merge" do
    it "returns itself" do
      expect(env.merge([])).to be env
    end
  end

  describe "#std?" do
    it "returns true if the environment contains :std" do
      env << :std
      expect(env).to be_std
    end

    it "returns false if the environment does not contain :std" do
      expect(env).not_to be_std
    end
  end

  describe "#userpaths?" do
    it "returns true if the environment contains :userpaths" do
      env << :userpaths
      expect(env).to use_userpaths
    end

    it "returns false if the environment does not contain :userpaths" do
      expect(env).not_to use_userpaths
    end
  end
end

describe BuildEnvironmentDSL do
  subject { double.extend(described_class) }

  context "single argument" do
    before(:each) do
      subject.instance_eval do
        env :userpaths
      end
    end

    its(:env) { is_expected.to use_userpaths }
  end

  context "multiple arguments" do
    before(:each) do
      subject.instance_eval do
        env :userpaths, :std
      end
    end

    its(:env) { is_expected.to be_std }
    its(:env) { is_expected.to use_userpaths }
  end
end