lib/sucker_punch/testing/inline.rb
require 'sucker_punch'
# Include this in your tests to simulate
# immediate execution of your asynchronous jobs
#
# class LogJob
# include SuckerPunch::Job
#
# def perform(*args)
# # log the things
# end
# end
#
# To trigger asynchronous job:
#
# LogJob.perform_async(1, 2, 3)
#
# Include inline testing lib:
#
# require 'sucker_punch/testing/inline'
#
# LogJob.perform_async(1, 2, 3) is now synchronous
# LogJob.perform_in(1, 2, 3) is now synchronous
#
module SuckerPunch
module Job
module ClassMethods
def perform_async(*args)
self.new.perform(*args)
end
ruby2_keywords(:perform_async) if respond_to?(:ruby2_keywords, true)
def perform_in(_, *args)
self.new.perform(*args)
end
ruby2_keywords(:perform_in) if respond_to?(:ruby2_keywords, true)
end
end
end