Sha256: af9a96f1620c42cd8e6835e19e43c9cbaea6b85a3cb0331fbaba2518ce7f62e9

Contents?: true

Size: 1.97 KB

Versions: 6

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'
require 'ey-core/cli/recipes/apply'

describe Ey::Core::Cli::Recipes::Apply do
  set_up_cli

  before(:each) do
    allow_any_instance_of(described_class).
      to receive(:run_chef).
      with(any_args).
      and_return(true)
  end

  context 'ey-core recipes apply --main' do
    arguments '--main'

    it 'performs a main chef run' do
      expect(cli).to receive(:run_chef).with('main', environment)

      execute
      expect(kernel.exit_status).to eql(0)
    end
  end

  context 'ey-core recipes apply --custom' do
    arguments '--custom'

    it 'performs a custom chef run' do
      expect(cli).to receive(:run_chef).with('custom', environment)
      
      execute
      expect(kernel.exit_status).to eql(0)
    end
  end

  context 'ey-core recipes apply --quick' do
    arguments '--quick'

    it 'performs a quick chef run' do
      expect(cli).to receive(:run_chef).with('quick', environment)
      
      execute
      expect(kernel.exit_status).to eql(0)
    end
  end

  context 'ey-core recipes apply --full' do
    arguments '--full'

    it 'performs both a main and a custom chef run' do
      expect(cli).to receive(:run_chef).with('main', environment)
      expect(cli).to receive(:run_chef).with('custom', environment)
      
      execute
      expect(kernel.exit_status).to eql(0)
    end
  end

  context 'attempting to use more than one run type flag' do
    let(:run_type_flags) {['--main', '--custom', '--quick', '--full']}
    let(:combinations) {run_type_flags.combination(2).to_a}

    it 'aborts with advice regarding the run type flags' do
      expect(kernel).
        to receive(:abort).
        with('Only one of --main, --custom, --quick, and --full may be specified.').
        and_call_original.
        exactly(combinations.length).
        times

      combinations.each do |combination|
        attempt = described_class.new(combination, stdin, stdout, stderr, kernel)

        expect(attempt.execute!).not_to eql(0)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ey-core-3.1.8 spec/ey-core/cli/recipes/apply_spec.rb
ey-core-3.1.7 spec/ey-core/cli/recipes/apply_spec.rb
ey-core-3.1.6 spec/ey-core/cli/recipes/apply_spec.rb
ey-core-3.1.5 spec/ey-core/cli/recipes/apply_spec.rb
ey-core-3.1.4 spec/ey-core/cli/recipes/apply_spec.rb
ey-core-3.1.3 spec/ey-core/cli/recipes/apply_spec.rb