Sha256: d4c8d69cd2931f02c62d97441869ab85b2207b79e45b75ddf30558796bd5476a

Contents?: true

Size: 1.66 KB

Versions: 33

Compression:

Stored size: 1.66 KB

Contents

describe Pheme do
  describe ".configure" do
    let(:sns_client) { double }
    let(:sqs_client) { double }
    let(:custom_logger) { double }

    it "sets global configuration" do
      expect(described_class.configuration.sns_client).to be_nil
      expect(described_class.configuration.sqs_client).to be_nil
      expect(described_class.configuration.logger).to be_a(Logger)

      described_class.configure do |config|
        config.sns_client = sns_client
        config.sqs_client = sqs_client
        config.logger = custom_logger
      end

      expect(described_class.configuration.sns_client).to eq(sns_client)
      expect(described_class.configuration.sqs_client).to eq(sqs_client)
      expect(described_class.configuration.logger).to eq(custom_logger)
    end
  end

  describe Pheme::Configuration do
    describe '.validate!' do
      subject { configuration.validate! }

      let(:configuration) { described_class.new }

      context 'empty configuration' do
        it 'is invalid when empty' do
          expect { subject }.to raise_error(StandardError)
        end
      end

      context 'all mandatory attributes provided' do
        let(:sns_client) { instance_double('Aws::SNS::Client') }
        let(:sqs_client) { instance_double('Aws::SQS::Client') }

        before do
          allow(sns_client).to receive(:is_a?).with(Aws::SNS::Client).and_return(true)
          allow(sqs_client).to receive(:is_a?).with(Aws::SQS::Client).and_return(true)

          configuration.sns_client = sns_client
          configuration.sqs_client = sqs_client
        end

        it 'is valid' do
          expect { subject }.not_to raise_error
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
pheme-5.1.1 spec/configuration_spec.rb
pheme-5.1.0 spec/configuration_spec.rb
pheme-5.0.10 spec/configuration_spec.rb
pheme-5.0.9 spec/configuration_spec.rb
pheme-5.0.8 spec/configuration_spec.rb
pheme-5.0.7 spec/configuration_spec.rb
pheme-5.0.6 spec/configuration_spec.rb
pheme-5.0.5 spec/configuration_spec.rb
pheme-5.0.4 spec/configuration_spec.rb
pheme-5.0.3 spec/configuration_spec.rb
pheme-5.0.2 spec/configuration_spec.rb
pheme-5.0.1 spec/configuration_spec.rb
pheme-5.0.0 spec/configuration_spec.rb
pheme-4.1.1 spec/configuration_spec.rb
pheme-4.1.0 spec/configuration_spec.rb
pheme-4.0.15 spec/configuration_spec.rb
pheme-4.0.14 spec/configuration_spec.rb
pheme-4.0.13 spec/configuration_spec.rb
pheme-4.0.12 spec/configuration_spec.rb
pheme-4.0.11 spec/configuration_spec.rb