作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我希望我的后台作业能够内联运行某些标记测试。我可以通过用 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
文件中执行此操作:
ActiveJob::Base.queue_adapter = :test
关于ruby-on-rails - rspec rails 测试 : how can I force ActiveJob job's to run inline for certain tests?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37281665/
我是一名优秀的程序员,十分优秀!