Sha256: 8fd2452994b3bddeadd9365a05396888942b7f2dbc1118270757f774b9379705
Contents?: true
Size: 1.18 KB
Versions: 4
Compression:
Stored size: 1.18 KB
Contents
require "qe/testing" module Qe module EnqueueMatcher class Matcher attr_reader :worker, :options def initialize(worker) @worker = worker end def with(options) @options = options self end def matches?(block) block.call Qe.jobs.find do |job| condition = job[:worker] == worker condition = condition && job[:options] == options if options condition end != nil end def description "enqueue job for #{worker.inspect} worker" end def failure_message_for_should build_message "expect #{worker.inspect} to be enqueued" end def failure_message_for_should_not build_message "expect #{worker.inspect} not to be enqueued" end def build_message(base) base << (options.empty? ? "" : " with #{options.inspect}") end end # # expect {}.to enqueue(MailerWorker).with(options) # def enqueue(worker) Matcher.new(worker) end end end RSpec.configure do |config| config.include Qe::EnqueueMatcher config.before(:each) do Qe.adapter = Qe::Testing Qe.jobs.clear end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
qe-0.3.0 | lib/qe/testing/rspec.rb |
qe-0.2.1 | lib/qe/testing/rspec.rb |
qe-0.2.0 | lib/qe/testing/rspec.rb |
qe-0.1.3 | lib/qe/testing/rspec.rb |