我希望我的后台作业能够内联运行某些标记的测试。我可以通过包装测试来做到这一点perform_enqueued do
但我希望能够用元数据标记它们,并且如果可能的话,它会自动发生。
我尝试过以下方法:
it "does everything in the job too", perform_enqueued: true do
end
config.around(:each) do |example|
if example.metadata[:perform_enqueued]
perform_enqueued_jobs do
example.run
end
end
end
但这会导致错误:
undefined method `perform_enqueued_jobs=' for ActiveJob::QueueAdapters::InlineAdapter:Class
您需要将测试适配器设置为ActiveJob::QueueAdapters::TestAdapter
它响应.perform_enqueued_jobs =
。您可以在您的spec/rails_helper.rb
file:
ActiveJob::Base.queue_adapter = :test
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)