Sha256: a756bca475163b8060d234134c121e14e0c15e25953c0604c31ac46bbd0bf2d7

Contents?: true

Size: 1.57 KB

Versions: 8

Compression:

Stored size: 1.57 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(: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

8 entries across 8 versions & 1 rubygems

Version Path
opsicle-2.2.0 spec/opsicle/client_spec.rb
opsicle-2.1.0 spec/opsicle/client_spec.rb
opsicle-2.0.2 spec/opsicle/client_spec.rb
opsicle-2.0.1 spec/opsicle/client_spec.rb
opsicle-2.0.0 spec/opsicle/client_spec.rb
opsicle-1.1.1 spec/opsicle/client_spec.rb
opsicle-1.1.0 spec/opsicle/client_spec.rb
opsicle-1.0.1 spec/opsicle/client_spec.rb