aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cask/dsl/stanza_proxy_spec.rb
blob: 8949c5bd9337b2d27a3a215d2b79dc440ad6fbb8 (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
describe Hbc::DSL::StanzaProxy, :cask do
  let(:stanza_proxy) {
    described_class.new(Array) { [:foo, :bar, :cake] }
  }

  subject { stanza_proxy }
  it { is_expected.to be_a_proxy }
  it { is_expected.to respond_to(:pop) }
  its(:pop) { is_expected.to eq(:cake) }
  its(:type) { is_expected.to eq(Array) }
  its(:to_s) { is_expected.to eq("[:foo, :bar, :cake]") }

  describe "when initialized" do
    let(:initializing) {
      proc { |b| described_class.new(Array, &b) }
    }

    it "does not evaluate the block" do
      expect(&initializing).not_to yield_control
    end
  end

  describe "when receiving a message" do
    let(:receiving_a_message) {
      proc { |b| described_class.new(Array, &b).to_s }
    }

    it "evaluates the block" do
      expect(&receiving_a_message).to yield_with_no_args
    end
  end
end