Skip to content

Instantly share code, notes, and snippets.

@jameslafa
Created July 17, 2016 10:50
Show Gist options
  • Save jameslafa/c59717c2039c237d5dea95c81605d9b5 to your computer and use it in GitHub Desktop.
Save jameslafa/c59717c2039c237d5dea95c81605d9b5 to your computer and use it in GitHub Desktop.
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