Sha256: 72e5b9469d88bdeacc0750097ffd794a7426a440991c2578af73d622f79e4601

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

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
      capture_published_events rspec_config
      include_support rspec_config
    end

    def capture_published_events rspec_config
      rspec_config.before :each do

        TestingSupport.published_events = []

        allow(RabbitFeed::ProducerConnection.instance).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

2 entries across 2 versions & 1 rubygems

Version Path
rabbit_feed-2.3.1 lib/rabbit_feed/testing_support.rb
rabbit_feed-2.3.0 lib/rabbit_feed/testing_support.rb