Class: ActiveEventStore::HaveEnqueuedAsyncSubscriberFor

Inherits:
RSpec::Rails::Matchers::ActiveJob::HaveEnqueuedJob
  • Object
show all
Defined in:
lib/active_event_store/rspec/have_enqueued_async_subscriber_for.rb

Defined Under Namespace

Classes: EventMatcher

Instance Method Summary collapse

Constructor Details

#initialize(subscriber_class) ⇒ HaveEnqueuedAsyncSubscriberFor

Returns a new instance of HaveEnqueuedAsyncSubscriberFor.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/active_event_store/rspec/have_enqueued_async_subscriber_for.rb', line 43

def initialize(subscriber_class)
  subscriber_job = ActiveEventStore::SubscriberJob.for(subscriber_class)
  if subscriber_job.nil?
    raise(
      RSpec::Expectations::ExpectationNotMetError,
      "No such async subscriber: #{subscriber_class.name}"
    )
  end
  super(subscriber_job)
  on_queue("events_subscribers")
end

Instance Method Details

#matches?(block) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


59
60
61
62
63
# File 'lib/active_event_store/rspec/have_enqueued_async_subscriber_for.rb', line 59

def matches?(block)
  raise ArgumentError, "have_enqueued_async_subscriber_for only supports block expectations" unless block.is_a?(Proc)
  # Make sure that there is a transaction
  super(proc { ActiveRecord::Base.transaction(&block) })
end

#with(event) ⇒ Object



55
56
57
# File 'lib/active_event_store/rspec/have_enqueued_async_subscriber_for.rb', line 55

def with(event)
  super(EventMatcher.new(event))
end