test/publisher_test.rb in propono-0.0.1 vs test/publisher_test.rb in propono-0.1.0
- old
+ new
@@ -13,19 +13,43 @@
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
+ 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_call_sns_with_message
+ 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)
- Publisher.new.publish(topic, "Foobar")
+
+ 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")