Sha256: 603f94ad2dbcba6a67d91898f62a3eb92b8c2cc5d34734c55ba88bcf89ccc040

Contents?: true

Size: 1.37 KB

Versions: 14

Compression:

Stored size: 1.37 KB

Contents

module ClientHelpers

  def self.included(base)
    base.let(:subject) do
      described_class.new(File.basename($0))
    end

    base.let(:client) do
      instance_double(Kontena::Client, :client)
    end

    base.let(:token) do
      '1234567'
    end

    base.let(:current_grid) do
      'test-grid'
    end

    base.let(:settings) do
      {'current_server' => 'alias',
       'current_account' => 'kontena',
       'servers' => [
           {'name' => 'some_master', 'url' => 'some_master'},
           {'name' => 'alias', 'url' => 'someurl', 'token' => token, 'account' => 'master', 'grid' => current_grid},
       ]
      }
    end

    base.before(:each) do
      RSpec::Mocks.space.proxy_for(File).reset
      allow(subject).to receive(:client).and_return(client)
      allow(subject).to receive(:current_grid).and_return(current_grid)
      allow(File).to receive(:exist?).with(File.join(Dir.home, '.kontena/certs/.pem')).and_return(false)
      allow(File).to receive(:exist?).with(File.join(Dir.home, '.kontena_client.json')).and_return(true)
      allow(File).to receive(:readable?).with(File.join(Dir.home, '.kontena_client.json')).and_return(true)
      allow(File).to receive(:read).and_call_original
      allow(File).to receive(:read).with(File.join(Dir.home, '.kontena_client.json')).and_return(JSON.dump(settings))
      Kontena::Cli::Config.reset_instance
    end
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kontena-cli-1.3.0.pre1 spec/support/client_helpers.rb
kontena-cli-1.2.2 spec/support/client_helpers.rb
kontena-cli-1.2.2.rc2 spec/support/client_helpers.rb
kontena-cli-1.2.2.rc1 spec/support/client_helpers.rb
kontena-cli-1.2.1 spec/support/client_helpers.rb
kontena-cli-1.2.1.rc1 spec/support/client_helpers.rb
kontena-cli-1.2.0 spec/support/client_helpers.rb
kontena-cli-1.2.0.rc3 spec/support/client_helpers.rb
kontena-cli-1.2.0.rc2 spec/support/client_helpers.rb
kontena-cli-1.2.0.rc1 spec/support/client_helpers.rb
kontena-cli-1.2.0.pre3 spec/support/client_helpers.rb
kontena-cli-1.2.0.pre2 spec/support/client_helpers.rb
kontena-cli-1.2.0.pre1 spec/support/client_helpers.rb
kontena-cli-1.2.0.dev1 spec/support/client_helpers.rb