Use nice matcher for sidekiq job enqueues

openid
Marcin Kulik 11 years ago
parent 47629b84e9
commit 0b9ae12feb

@ -17,7 +17,8 @@ describe Api::AsciicastsController do
end
it 'enqueues snapshot capture' do
expect { post :create }.to change(SnapshotWorker.jobs, :size).by(1)
post :create
SnapshotWorker.should have_queued_job(asciicast.id)
end
it 'returns status 201' do

@ -0,0 +1,17 @@
RSpec::Matchers.define :have_queued_job do |*expected|
match do |actual|
actual.jobs.any? { |job| Array(expected) == job["args"] }
end
failure_message_for_should do |actual|
"expected that #{actual} would have a job queued with #{expected}"
end
failure_message_for_should_not do |actual|
"expected that #{actual} would not a have a job queued with #{expected}"
end
description do
"have a job queued with #{expected}"
end
end
Loading…
Cancel
Save