Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Expect Job being enqueued with args
RSpec.describe MyController, type: :controller do
include ActiveJob::TestHelper
describe "..." do
it "enqueues the job with the right arguments" do
expect {
@bookmark = post :create, {:bookmark => valid_attributes}
}.to have_enqueued_job(SlackNotifierJob).with { |args|
expect(args).to eq(["new_bookmark", @bookmark])
}
end
end
end
## Add in config/environments/test.rb
# Enable: ActiveJob::Base.queue_adapter.enqueued_jobs
config.active_job.queue_adapter = :test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment