Sha256: c890a7eb233682f5625d191f2d25af5476eea845dc502e757573726cd9eacd0a

Contents?: true

Size: 1.61 KB

Versions: 11

Compression:

Stored size: 1.61 KB

Contents

require_relative "../../../spec_helper"
require "kontena/cli/stacks/build_command"

describe Kontena::Cli::Stacks::BuildCommand do

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

  describe '#execute' do
    let(:stack) do
      {
        'name' => 'stack-a',
        'stack' => 'user/stack-a',
        'version' => '1.0.0',
        'services' => [
          service
        ]
      }
    end

    let(:service) do
      {
        'name' => 'test',
        'image' => 'registry.kontena.local/test:latest',
        'build' => {
          'context' => File.expand_path('.')
        }
      }
    end

    describe '#execute' do
      before(:each) do
        allow(subject).to receive(:require_config_file).with('kontena.yml').and_return(true)
        allow(subject).to receive(:stack_from_yaml).with('kontena.yml').and_return(stack)
        allow(subject).to receive(:system).and_return(true)
      end

      it 'requires config file' do
        expect(subject).to receive(:require_config_file).with('kontena.yml').and_return(true)
        subject.run([])
      end

      it 'reads stack file' do
        expect(subject).to receive(:stack_from_yaml).with('kontena.yml').and_return(stack)
        subject.run([])
      end

      it 'builds docker image' do
        expect(subject).to receive(:system).with('docker', 'build', '-t', 'registry.kontena.local/test:latest', '--pull', File.expand_path('.'))
        subject.run([])
      end

      it 'pushes docker image' do
        expect(subject).to receive(:system).with('docker', 'push', 'registry.kontena.local/test:latest')
        subject.run([])
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
kontena-cli-1.1.0.pre1 spec/kontena/cli/stacks/build_command_spec.rb
kontena-cli-1.0.6 spec/kontena/cli/stacks/build_command_spec.rb
kontena-cli-1.0.6.rc1 spec/kontena/cli/stacks/build_command_spec.rb
kontena-cli-1.0.5 spec/kontena/cli/stacks/build_command_spec.rb
kontena-cli-1.0.5.rc1 spec/kontena/cli/stacks/build_command_spec.rb
kontena-cli-1.0.5.pre1 spec/kontena/cli/stacks/build_command_spec.rb
kontena-cli-1.0.4 spec/kontena/cli/stacks/build_command_spec.rb
kontena-cli-1.0.4.rc2 spec/kontena/cli/stacks/build_command_spec.rb
kontena-cli-1.0.4.rc1 spec/kontena/cli/stacks/build_command_spec.rb
kontena-cli-1.0.3 spec/kontena/cli/stacks/build_command_spec.rb
kontena-cli-1.0.3.rc1 spec/kontena/cli/stacks/build_command_spec.rb