File: base_spec.rb

package info (click to toggle)
r10k 5.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,228 kB
  • sloc: ruby: 18,180; makefile: 10; sh: 1
file content (31 lines) | stat: -rw-r--r-- 919 bytes parent folder | download | duplicates (5)
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
require 'spec_helper'
require 'r10k/source'

describe R10K::Source::Base do
  subject { described_class.new('base', '/some/nonexistent/path') }

  describe "accepting a visitor" do
    it "passes itself to the visitor" do
      visitor = spy('visitor')
      expect(visitor).to receive(:visit).with(:source, subject)
      subject.accept(visitor)
    end

    it "passes the visitor to each environment if the visitor yields" do
      visitor = spy('visitor')
      expect(visitor).to receive(:visit) do |type, other, &block|
        expect(type).to eq :source
        expect(other).to eq subject
        block.call
      end

      env1 = spy('environment')
      expect(env1).to receive(:accept).with(visitor)
      env2 = spy('environment')
      expect(env2).to receive(:accept).with(visitor)

      expect(subject).to receive(:environments).and_return([env1, env2])
      subject.accept(visitor)
    end
  end
end