Sha256: 39ab6b14af0a6291f6306ad9338db76e6f3e73e10e5b9d98ab733b8bafd288be

Contents?: true

Size: 999 Bytes

Versions: 1

Compression:

Stored size: 999 Bytes

Contents

require File.expand_path('../test_helper', __FILE__)

module Propono
  class TopicCreatorTest < Minitest::Test

    def test_create_topic_called_on_sns
      sns = mock()
      sns.expects(:create_topic).with("foobar").returns(mock(body: { "TopicArn" => @arn}))

      creator = TopicCreator.new("foobar")
      creator.stubs(sns: sns)

      creator.find_or_create
    end

    def test_returns_arn
      arn = "malcs_happy_arn"
      create_topic_result = mock(body: { "TopicArn" => arn})
      sns = mock(create_topic: create_topic_result)

      creator = TopicCreator.new("foobar")
      creator.stubs(sns: sns)

      assert_equal arn, creator.find_or_create
    end

    def test_should_raise_exception_if_no_arn_returned
      create_topic_result = mock(body: {})
      sns = mock(create_topic: create_topic_result)

      creator = TopicCreator.new("foobar")
      creator.stubs(sns: sns)

      assert_raises TopicCreatorError do
        creator.find_or_create
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
propono-0.0.1 test/topic_creator_test.rb