Sha256: e151500e89fee079e473d9fc50ba60a47303a451e6b03dfe3c2f100eb87f4612

Contents?: true

Size: 1.51 KB

Versions: 16

Compression:

Stored size: 1.51 KB

Contents

require "kontena/cli/helpers/exec_helper"

describe Kontena::Cli::Helpers::ExecHelper do

  include ClientHelpers

  let(:described_class) do
    Class.new do
      include Kontena::Cli::Helpers::ExecHelper
      def initialize(*args)
      end
    end
  end

  describe '#ws_url' do
    it 'returns an exec url for a container id' do
      expect(subject).to receive(:require_current_master).and_return(double(url: 'http://someurl/'))
      expect(subject.ws_url('abcd1234')).to eq 'ws://someurl/v1/containers/abcd1234/exec'
    end

    it 'also works when the url does not have a trailing slash' do
      expect(subject).to receive(:require_current_master).and_return(double(url: 'http://someurl'))
      expect(subject.ws_url('abcd1234')).to eq 'ws://someurl/v1/containers/abcd1234/exec'
    end

    context 'query params' do
      before(:each) do
        allow(subject).to receive(:require_current_master).and_return(double(url: 'http://someurl'))
      end

      it 'can add the interactive query param' do
        expect(subject.ws_url('abcd1234', interactive: true)).to eq 'ws://someurl/v1/containers/abcd1234/exec?interactive=true'
      end

      it 'can add the shell query param' do
        expect(subject.ws_url('abcd1234', shell: true)).to eq 'ws://someurl/v1/containers/abcd1234/exec?shell=true'
      end

      it 'can add both query params' do
        expect(subject.ws_url('abcd1234', shell: true, interactive: true)).to eq 'ws://someurl/v1/containers/abcd1234/exec?interactive=true&shell=true'
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
kontena-cli-1.3.5 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.5.rc1 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.4.0.pre1 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.4 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.4.rc1 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.3 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.3.rc1 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.2 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.2.rc2 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.2.rc1 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.1 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.1.rc2 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.1.rc1 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.0 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.0.rc4 spec/kontena/cli/helpers/exec_helper_spec.rb
kontena-cli-1.3.0.rc3 spec/kontena/cli/helpers/exec_helper_spec.rb