test/queue_subscriber_test.rb in propono-0.1.0 vs test/queue_subscriber_test.rb in propono-0.2.0

- old
+ new

@@ -1,36 +1,50 @@ require File.expand_path('../test_helper', __FILE__) module Propono class QueueSubscriberTest < Minitest::Test def test_create_topic - topic = 'foobar' - TopicCreator.expects(:find_or_create).with(topic) - QueueSubscriber.subscribe(topic) + topic_id = 'foobar' + topic = Topic.new(topic_id) + TopicCreator.expects(:find_or_create).with(topic_id).returns(topic) + QueueSubscriber.subscribe(topic_id) end def test_sqs_create_is_called - topic = "Foobar" - subscriber = QueueSubscriber.new(topic) + topic_id = "Foobar" + subscriber = QueueSubscriber.new(topic_id) - TopicCreator.stubs(find_or_create: "1123") + TopicCreator.stubs(find_or_create: Topic.new("1123")) sqs = mock() sqs.expects(:create_queue).with(subscriber.send(:queue_name)).returns(mock(body: {'QueueUrl' => Fog::AWS::SQS::Mock::QueueUrl})) QueueCreator.any_instance.stubs(sqs: sqs) subscriber.subscribe end def test_subscriber_queue_name - skip + config.application_name = "MyApp" + + topic_id = "Foobar" + subscriber = QueueSubscriber.new(topic_id) + + assert_equal subscriber.send(:queue_name), "MyApp::Foobar" end + def test_subscriber_queue_name_with_spaces + config.application_name = "My App" + + topic_id = "Foobar" + subscriber = QueueSubscriber.new(topic_id) + + assert_equal subscriber.send(:queue_name), "My_App::Foobar" + end + def test_subscribe_calls_subscribe arn = "arn123" - queue_url = - TopicCreator.stubs(find_or_create: arn) + TopicCreator.stubs(find_or_create: Topic.new(arn)) QueueCreator.stubs(find_or_create: Queue.new(Fog::AWS::SQS::Mock::QueueUrl)) sns = mock() sns.expects(:subscribe).with(arn, Fog::AWS::SQS::Mock::QueueArn, 'sqs') subscriber = QueueSubscriber.new("Some topic")