Sha256: 9a0f5d766bef8ffb85d3839308310a98ea591b693dd866085de45a673f149953

Contents?: true

Size: 862 Bytes

Versions: 16

Compression:

Stored size: 862 Bytes

Contents

require 'spec_helper'

describe Aptible::CLI::Agent do
  let(:token) { 'some-token' }
  let(:operation) { Fabricate(:operation) }

  before do
    allow(subject).to receive(:fetch_token).and_return(token)
    allow(subject).to receive(:say) { |m| messages << m }
  end

  describe '#operation:cancel' do
    it 'fails if the operation cannot be found' do
      expect(Aptible::Api::Operation).to receive(:find).with(1, token: token)
        .and_return(nil)

      expect { subject.send('operation:cancel', 1) }
        .to raise_error('Operation #1 not found')
    end

    it 'sets the cancelled flag on the operation' do
      expect(Aptible::Api::Operation).to receive(:find).with(1, token: token)
        .and_return(operation)

      expect(operation).to receive(:update!).with(cancelled: true)

      subject.send('operation:cancel', 1)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aptible-cli-0.14.1 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.14.0 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.13.0 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.12.0 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.11.2 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.11.1 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.11.0 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.10.0 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.9.0 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.8.6 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.8.5 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.8.4 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.8.3 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.8.2 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.8.1 spec/aptible/cli/subcommands/operation_spec.rb
aptible-cli-0.8.0 spec/aptible/cli/subcommands/operation_spec.rb