Sha256: fde8cfc50080a5c517a9034346bfbce730adee5abf63ec0ecfa818c623c09368

Contents?: true

Size: 1.4 KB

Versions: 3

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

class Convection::Model::Template::Resource
  describe SNSSubscription do
    let(:template) do
      Convection.template do
        sns_subscription 'MySubscription' do
          endpoint 'failures@example.com'
          protocol 'email'
          topic_arn 'arn:aws:sns:us-west-2:123456789012:example-topic'
          filter_policy 'Type' => 'Notification', 'MessageId' => 'e3c4e17a-819b-5d95-a0e8-b306c25afda0', 'MessageAttributes' => { 'AttributeName' => 'Name', 'KeyType' => 'HASH' }
        end
      end
    end

    subject do
      template_json
        .fetch('Resources')
        .fetch('MySubscription')
        .fetch('Properties')
    end

    it 'sets the Endpoint' do
      expect(subject['Endpoint']).to eq('failures@example.com')
    end

    it 'sets the Protocol' do
      expect(subject['Protocol']).to eq('email')
    end

    it 'sets the TopicArn' do
      expect(subject['TopicArn']).to eq('arn:aws:sns:us-west-2:123456789012:example-topic')
    end

    it 'sets the FilterPolicy' do
      expect(subject['FilterPolicy']).to include('Type' => 'Notification',
                                                 'MessageId' => 'e3c4e17a-819b-5d95-a0e8-b306c25afda0',
                                                 'MessageAttributes' => { 'AttributeName' => 'Name', 'KeyType' => 'HASH' })
    end

    private

    def template_json
      JSON.parse(template.to_json)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
convection-2.3.1 spec/convection/model/template/resource/aws_sns_subscription_spec.rb
convection-2.3.0 spec/convection/model/template/resource/aws_sns_subscription_spec.rb
convection-2.2.29 spec/convection/model/template/resource/aws_sns_subscription_spec.rb