Sha256: f9e55e27d2e1f53ee3df58a9ed15d9330d29c71da6fef82567c617651225e933

Contents?: true

Size: 1.58 KB

Versions: 14

Compression:

Stored size: 1.58 KB

Contents

require 'spec_helper'

describe DispatchRider::NotificationServices::AwsSns do
  let(:amazon_resource_name) { "arn:aws:sns:us-west-2:123456789012:GeneralTopic" }

  describe "#notifier_builder" do
    it "returns the notifier builder" do
      expect(subject.notifier_builder).to eq(AWS::SNS)
    end
  end

  describe "#channel_registrar_builder" do
    it "returns the channel registrar builder" do
      expect(subject.channel_registrar_builder).to eq(DispatchRider::Registrars::SnsChannel)
    end
  end

  describe "#publish_to_channel" do
    let(:channel) { double(:channel) }
    let(:message) { DispatchRider::Message.new(subject: :test_handler, body: { "bar" => "baz" }) }

    # @note: This is tested this way cause you don't really wanna post a message to the actual service.
    it "publishes the message to the channels" do
      expect(channel).to receive(:publish).with(kind_of String) do |serialized_message|
                           expected = {
                             "subject" => "test_handler",
                             "body" => { "bar" => "baz" }
                           }
                           expect(JSON.parse(serialized_message)).to eq(expected)
                         end

      subject.publish_to_channel(channel, message: message)
    end
  end

  describe "#channel" do
    before { allow(subject).to receive(:channel_registrar).and_return(foo: amazon_resource_name) }

    let(:topics) { double :sns_topics }
    let(:topic) { double :sns_topic }

    it "returns the channel" do
      expect(subject.channel(:foo).arn).to eq(amazon_resource_name)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
dispatch-rider-1.9.0 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.8.6 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.8.5 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.8.4 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.8.3 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.8.2 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.8.1 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.8.0 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.7.2 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.7.1 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.7.0 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.6.2 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.6.1 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
dispatch-rider-1.6.0 spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb