Sha256: 1c0049fa6ae18c63e0ff0d0cafcb76dd28e6ffb159c792faf622bff8f689dbc7

Contents?: true

Size: 1.6 KB

Versions: 7

Compression:

Stored size: 1.6 KB

Contents

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

describe Kontena::Cli::Stacks::InstallCommand do

  include ClientHelpers

  describe '#execute' do
    let(:stack) do
      {
        name: 'stack-a',
        registry: 'file://kontena.yml',
        source: "YAML content",
        services: []
      }
    end

    before(:each) do
      allow(subject).to receive(:yaml_content).and_return("YAML content")
    end

    it 'requires api url' do
      allow(subject).to receive(:stack_from_yaml).with('kontena.yml').and_return(stack)
      expect(subject).to receive(:require_api_url).once
      subject.run([])
    end

    it 'requires token' do
      allow(subject).to receive(:stack_from_yaml).with('kontena.yml').and_return(stack)
      expect(subject).to receive(:require_token).and_return(token)
      subject.run([])
    end

    it 'sends stack to master' 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)
      expect(client).to receive(:post).with(
        'grids/test-grid/stacks', stack
      )
      subject.run([])
    end

    it 'allows to override stack name' 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)
      stack_b = stack
      stack_b[:name] = 'stack-b'
      expect(client).to receive(:post).with(
        'grids/test-grid/stacks', stack
      )
      subject.run(['--name', 'stack-b'])
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kontena-cli-1.0.0.pre2 spec/kontena/cli/stacks/install_command_spec.rb
kontena-cli-1.0.0.pre1 spec/kontena/cli/stacks/install_command_spec.rb
kontena-cli-0.17.0.pre5 spec/kontena/cli/stacks/install_command_spec.rb
kontena-cli-0.17.0.pre4 spec/kontena/cli/stacks/install_command_spec.rb
kontena-cli-0.17.0.pre3 spec/kontena/cli/stacks/install_command_spec.rb
kontena-cli-0.17.0.pre2 spec/kontena/cli/stacks/install_command_spec.rb
kontena-cli-0.17.0.pre1 spec/kontena/cli/stacks/install_command_spec.rb