Sha256: bb85b924801a9fcc96d1601223535a0010ef2d7d54ad66eb8756db1fb7ea84ae

Contents?: true

Size: 1.64 KB

Versions: 29

Compression:

Stored size: 1.64 KB

Contents

require "spec_helper"
require "opsicle"

module Opsicle
  describe Client do
    subject { Client.new('derp') }
    let(:aws_client) { double }
    let(:config) { double }
    before do
      mock_keys = {access_key_id: 'key', secret_access_key: 'secret'}
      allow(config).to receive(:aws_credentials).and_return(mock_keys)
      allow(config).to receive(:opsworks_config).and_return({ stack_id: 'stack', app_id: 'app', something_else: 'true' })
      allow(config).to receive(:opsworks_region).and_return('us-east-1')
      allow(Config).to receive(:new).and_return(config)
      allow(Config).to receive(:instance).and_return(config)
      allow(Aws::OpsWorks::Client).to receive(:new).and_return(aws_client)
      allow(Aws::S3::Client).to receive(:new).and_return(aws_client)
      allow(config).to receive(:configure_aws_environment!).with("derp")
      allow(aws_client).to receive(:configure_aws_environment!).with("derp")
      allow(subject).to receive(:configure_aws_environment!).with("derp")
      allow(Client).to receive(:configure_aws_environment!).with("derp")
    end

    context "#run_command" do
      it "calls out to the aws client with all the config options" do
        expect(aws_client).to receive(:create_deployment).with(
          hash_including(
            command: { name: 'deploy', args: {} },
            stack_id: 'stack',
            app_id: 'app'
          )
        )
        subject.run_command('deploy')
      end
      it "removes extra options from the opsworks config" do
        expect(aws_client).to receive(:create_deployment).with(hash_excluding(:something_else))
        subject.run_command('deploy')
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
opsicle-2.15.0 spec/opsicle/client_spec.rb
opsicle-2.14.2 spec/opsicle/client_spec.rb
opsicle-2.14.1 spec/opsicle/client_spec.rb
opsicle-2.14.0 spec/opsicle/client_spec.rb
opsicle-2.13.1 spec/opsicle/client_spec.rb
opsicle-2.13.0 spec/opsicle/client_spec.rb
opsicle-2.12.5 spec/opsicle/client_spec.rb
opsicle-2.12.3 spec/opsicle/client_spec.rb
opsicle-2.12.2 spec/opsicle/client_spec.rb
opsicle-2.12.1 spec/opsicle/client_spec.rb
opsicle-2.12.0 spec/opsicle/client_spec.rb
opsicle-2.11.3 spec/opsicle/client_spec.rb
opsicle-2.11.1 spec/opsicle/client_spec.rb
opsicle-2.11.0 spec/opsicle/client_spec.rb
opsicle-2.10.1 spec/opsicle/client_spec.rb
opsicle-2.10.0 spec/opsicle/client_spec.rb
opsicle-2.9.6 spec/opsicle/client_spec.rb
opsicle-2.9.4 spec/opsicle/client_spec.rb
opsicle-2.9.3 spec/opsicle/client_spec.rb
opsicle-2.9.2 spec/opsicle/client_spec.rb