Sha256: 087808fc287d9723b1452a6555d30ef3c24d0786b82909c5db8423e20e5575d8

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

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)
    end

    def test_sqs_create_is_called
      topic = "Foobar"
      subscriber = QueueSubscriber.new(topic)

      TopicCreator.stubs(find_or_create: "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
    end

    def test_subscribe_calls_subscribe
      arn = "arn123"
      queue_url = 

      TopicCreator.stubs(find_or_create: 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")
      subscriber.stubs(sns: sns)
      subscriber.subscribe
    end

    def test_subscribe_saves_queue
      queue = Queue.new(Fog::AWS::SQS::Mock::QueueUrl)

      QueueCreator.expects(:find_or_create).returns(queue)
      subscriber = QueueSubscriber.new("Some Topic")
      subscriber.subscribe
      assert_equal queue, subscriber.queue
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
propono-0.1.0 test/queue_subscriber_test.rb