Sha256: 33601877c3b714846d2cc1205ff4cf2d51e0753594b85e70a562c3893ce2c90d

Contents?: true

Size: 1.45 KB

Versions: 28

Compression:

Stored size: 1.45 KB

Contents

require_relative "../../../spec_helper"
require 'kontena/cli/master/current_command'

describe Kontena::Cli::Master::CurrentCommand do
  let(:settings) do
    {'current_server' => 'alias',
      'servers' => [
        {'name' => 'some_master', 'url' => 'some_master'},
        {'name' => 'alias', 'url' => 'someurl', 'token' => '123456'}
      ]
    }
  end

  let(:subject) { described_class.new(File.basename($0)) }

  describe '#execute' do
    it 'puts master name and URL' do
      allow(subject).to receive(:settings).and_return(settings)

      expect {
        subject.run([])
      }.to output(/alias.*someurl/).to_stdout
    end

    it 'only outputs name if name-flag is set' do
      allow(subject).to receive(:settings).and_return(settings)

      expect {
        subject.run(['--name'])
      }.to output("alias\n").to_stdout
    end

    it 'does not raise error when logged in' do
      allow(subject).to receive(:settings).and_return(settings)

      expect {
        subject.run([])
      }.to_not raise_error
    end

    it 'raises error when not logged in' do
      allow(subject).to receive(:settings).and_return(
        {
            'current_server' => nil,
            'servers' => [
                {'name' => 'some_master', 'url' => 'some_master'},
                {'name' => 'alias', 'url' => 'someurl', 'token' => '123456'}
            ]
        }
      )

      expect {
        subject.run([])
      }.to raise_error(ArgumentError)
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
kontena-cli-0.15.5 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.5.rc2 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.5.rc1 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.4 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.4.rc2 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.4.rc1 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.4.pre1 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.3 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.2 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.1 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.0 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.0.rc3 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.0.rc2 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.15.0.rc1 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.14.7 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.14.6 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.14.5 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.14.4 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.14.3 spec/kontena/cli/master/current_command_spec.rb
kontena-cli-0.14.2 spec/kontena/cli/master/current_command_spec.rb