Created
August 4, 2017 03:06
-
-
Save greatghoul/6cea850cc77f4c5d8ee0293d0d3a4729 to your computer and use it in GitHub Desktop.
RSpec: Execute jobs triggered in specific methods.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# spec/support/jobs.rb | |
ActiveJob::Base.queue_adapter = :test | |
module PerformJobsSupport | |
def perform_jobs_on(klass, *method_names) | |
klass.class_eval do | |
include ActiveJob::TestHelper | |
method_names.each do |method_name| | |
alias_method "origin_#{method_name}", method_name | |
define_method method_name do |*args, &block| | |
perform_enqueued_jobs do | |
send("origin_#{method_name}", *args, &block) | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment