Sha256: 92f91973fecb919ecdd7fd1721a09b08e0b3b1f2709f023e3a75e42af9ec6d7f
Contents?: true
Size: 1.66 KB
Versions: 9
Compression:
Stored size: 1.66 KB
Contents
require File.expand_path('../test_helper', __FILE__) module Propono class PublisherTest < Minitest::Test def test_initialization notifier = Publisher.new refute notifier.nil? end def test_self_publish_calls_publish topic = "topic123" message = "message123" Publisher.any_instance.expects(:publish).with(topic, message) Publisher.new.publish(topic, message) end def test_publish_should_call_sns_on_correct_topic_and_message topic = "topic123" message = "message123" topic_arn = "arn123" TopicCreator.stubs(find_or_create: topic_arn) sns = mock() sns.expects(:publish).with(topic_arn, message) publisher = Publisher.new publisher.stubs(sns: sns) publisher.publish(topic, message) end def test_publish_should_propogate_exception_on_topic_creation_error TopicCreator.stubs(:find_or_create).raises(TopicCreatorError) assert_raises(TopicCreatorError) do Publisher.publish("topic", "message") end end def test_publish_creates_a_topic topic = "Malcs_topic" TopicCreator.expects(:find_or_create).with(topic) sns = mock() sns.stubs(:publish) publisher = Publisher.new publisher.stubs(sns: sns) publisher.publish(topic, "Foobar") end def test_publish_should_raise_exception_if_topic_is_nil assert_raises(PublisherError, "Topic is nil") do Publisher.publish(nil, "foobar") end end def test_publish_should_raise_exception_if_message_is_nil assert_raises(PublisherError, "Message is nil") do Publisher.publish("foobar", nil) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems