Sha256: b1a31af0c805101b9c86cd123c5586110a0c348ea85eb8479d1889c72e5980fe

Contents?: true

Size: 1.66 KB

Versions: 22

Compression:

Stored size: 1.66 KB

Contents

require "kontena/cli/apps/build_command"

describe Kontena::Cli::Apps::BuildCommand do
  include FixturesHelpers

  let(:subject) do
    described_class.new(File.basename($0))
  end

  let(:kontena_yml) do
    fixture('kontena-build.yml')
  end

  let(:mysql_yml) do
    fixture('kontena.yml')
  end

  let(:docker_compose_yml) do
    fixture('docker-compose.yml')
  end

  describe '#execute' do
    before(:each) do
      allow(subject).to receive(:current_dir).and_return("kontena-test")
      allow(File).to receive(:exists?).and_return(true)
      allow(File).to receive(:read).with("#{Dir.getwd}/kontena.yml").and_return(kontena_yml)
      allow(File).to receive(:read).with("#{Dir.getwd}/docker-compose.yml").and_return(docker_compose_yml)
    end

    it 'requests process_docker_images with services from yaml' do
      expect(subject).to receive(:process_docker_images) do |services, force_build, no_cache|
        expect(services.keys).to eq(['wordpress', 'mysql'])
      end
      subject.run([])
    end

    it 'requests process_docker_images with force_build' do
      expect(subject).to receive(:process_docker_images).with(anything, true, anything)
      subject.run([])
    end

    it 'requests process_docker_images with given no_cache option' do
      expect(subject).to receive(:process_docker_images).with(anything, anything, true)
      subject.run(['--no-cache'])
    end

    it 'raises error if no services found with build options' do
      allow(File).to receive(:read).with("#{Dir.getwd}/kontena.yml").and_return(mysql_yml)
      expect(subject).not_to receive(:process_docker_images)
      expect {
        subject.run([])
      }.to exit_with_error
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
kontena-cli-1.3.5 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.5.rc1 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.4.0.pre6 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.4.0.pre5 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.4.0.pre4 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.4.0.pre3 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.4.0.pre2 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.4.0.pre1 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.4 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.4.rc1 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.3 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.3.rc1 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.2 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.2.rc2 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.2.rc1 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.1 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.1.rc2 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.1.rc1 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.0 spec/kontena/cli/app/build_command_spec.rb
kontena-cli-1.3.0.rc4 spec/kontena/cli/app/build_command_spec.rb