Sha256: 288d63f8300fc011181fd5876ba2c17c407598c532481f3a3f54428e3ff1b1e0

Contents?: true

Size: 1.37 KB

Versions: 4

Compression:

Stored size: 1.37 KB

Contents

require 'ostruct'
require 'spec_helper'

class App < OpenStruct
end

class Service < OpenStruct
end

class Operation < OpenStruct
end

describe Aptible::CLI::Agent do
  before { subject.stub(:ask) }
  before { subject.stub(:save_token) }
  before { subject.stub(:fetch_token) { double 'token' } }

  let(:service) { Service.new(process_type: 'web') }
  let(:op) { Operation.new(status: 'succeeded') }
  let(:apps) { [App.new(handle: 'hello', services: [service])] }

  describe '#apps:scale' do
    it 'should pass given correct parameters' do
      allow(service).to receive(:create_operation) { op }
      allow(subject).to receive(:options) { { app: 'hello' } }

      allow(Aptible::Api::App).to receive(:all) { apps }
      subject.send('apps:scale', 'web', 3)
    end

    it 'should fail if app is non-existent' do
      allow(service).to receive(:create_operation) { op }
      allow(Aptible::Api::App).to receive(:all) { apps }

      expect do
        subject.send('apps:scale', 'web', 3)
      end.to raise_error(Thor::Error)
    end

    it 'should fail if number is not a valid number' do
      allow(service).to receive(:create_operation) { op }
      allow(subject).to receive(:options) { { app: 'hello' } }

      allow(Aptible::Api::App).to receive(:all) { apps }
      expect do
        subject.send('apps:scale', 'web', 'potato')
      end.to raise_error(ArgumentError)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aptible-cli-0.5.12 spec/aptible/cli/subcommands/apps_spec.rb
aptible-cli-0.5.11 spec/aptible/cli/subcommands/apps_spec.rb
aptible-cli-0.5.10 spec/aptible/cli/subcommands/apps_spec.rb
aptible-cli-0.5.9 spec/aptible/cli/subcommands/apps_spec.rb