Sha256: 592a221ff13ad238c6c6785f3b9245d22f855b8f681679c3dc0afa27f879e491

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

require 'rabbit_feed/testing_support/rspec_matchers/publish_event'
require 'rabbit_feed/testing_support/test_rabbit_feed_consumer'
require 'rabbit_feed/testing_support/testing_helpers'

module RabbitFeed
  module TestingSupport
    extend self

    attr_accessor :published_events

    def setup rspec_config
      RabbitFeed.environment ||= 'test'
      capture_published_events rspec_config
      include_support rspec_config
    end

    def capture_published_events rspec_config
      rspec_config.before :each do

        TestingSupport.published_events = []
        mock_connection = double(:rabbitmq_connection)
        allow(RabbitFeed::ProducerConnection).to receive(:instance).and_return(mock_connection)
        allow(mock_connection).to receive(:publish) do |serialized_event, routing_key|
          TestingSupport.published_events << (Event.deserialize serialized_event)
        end
      end
    end

    def include_support rspec_config
      rspec_config.include(RabbitFeed::TestingSupport::RSpecMatchers)
      rspec_config.include(RabbitFeed::TestingSupport::TestingHelpers)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rabbit_feed-2.3.3 lib/rabbit_feed/testing_support.rb