Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/rspec/rails/matchers/active_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ def does_not_match?(proc)

!matches?(proc)
end

def supports_block_expectations?
false
end
end

# @private
Expand Down Expand Up @@ -352,6 +356,10 @@ def matches?(job)
@job = job
check(queue_adapter.performed_jobs)
end

def supports_block_expectations?
false
end
end
end

Expand Down
12 changes: 12 additions & 0 deletions spec/rspec/rails/matchers/active_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,12 @@ def perform; raise StandardError; end
describe "have_been_enqueued" do
before { ActiveJob::Base.queue_adapter.enqueued_jobs.clear }

it "raises RSpec::Expectations::ExpectationNotMetError when Proc passed to expect" do
expect {
expect { heavy_lifting_job }.to have_been_enqueued
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)
end

it "passes with default jobs count (exactly one)" do
heavy_lifting_job.perform_later
expect(heavy_lifting_job).to have_been_enqueued
Expand Down Expand Up @@ -861,6 +867,12 @@ def perform; raise StandardError; end
stub_const('HeavyLiftingJob', heavy_lifting_job)
end

it "raises RSpec::Expectations::ExpectationNotMetError when Proc passed to expect" do
expect {
expect { heavy_lifting_job }.to have_been_performed
}.to raise_error(RSpec::Expectations::ExpectationNotMetError)
end

it "passes with default jobs count (exactly one)" do
heavy_lifting_job.perform_later
expect(heavy_lifting_job).to have_been_performed
Expand Down