Sha256: 0604d1c5ffb60de914a866b52909991466403dbc4802818d1724b2697bb34b4a

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 KB

Contents

require_relative "../../spec_helper"
require "kontena/cli/common"

describe Kontena::Cli::Common do

  let(:subject) do
    Class.new do
      include Kontena::Cli::Common
    end.new
  end

  before(:each) do
    allow(subject).to receive(:settings).and_return({'server' => {}})
    allow(subject).to receive(:save_settings)
  end

  describe '#current_grid' do
    it 'returns nil by default' do
      expect(subject.current_grid).to eq(nil)
    end

    it 'returns grid from env' do
      expect(ENV).to receive(:[]).with('KONTENA_GRID').and_return('foo')
      expect(subject.current_grid).to eq('foo')
    end
  end

  describe '#api_url' do
    it 'raises error by default' do
      expect {
        subject.api_url
      }.to raise_error(ArgumentError)
    end

    it 'return url from env' do
      expect(ENV).to receive(:[]).with('KONTENA_URL').and_return('https://domain.com')
      expect(subject.api_url).to eq('https://domain.com')
    end
  end

  describe '#require_token' do
    it 'raises error by default' do
      expect {
        subject.require_token
      }.to raise_error(ArgumentError)
    end

    it 'return token from env' do
      expect(ENV).to receive(:[]).with('KONTENA_TOKEN').and_return('secret_token')
      expect(subject.require_token).to eq('secret_token')
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kontena-cli-0.10.3 spec/kontena/cli/common_spec.rb
kontena-cli-0.10.2 spec/kontena/cli/common_spec.rb
kontena-cli-0.10.1 spec/kontena/cli/common_spec.rb
kontena-cli-0.10.0 spec/kontena/cli/common_spec.rb
kontena-cli-0.9.3 spec/kontena/cli/common_spec.rb
kontena-cli-0.9.2 spec/kontena/cli/common_spec.rb
kontena-cli-0.9.1 spec/kontena/cli/common_spec.rb
kontena-cli-0.9.0 spec/kontena/cli/common_spec.rb