我最近将一个项目升级到了 Rails 5.1。
- 已修复所有弃用警告。
- 所有测试都通过(我使用
rspec-rails
) - 使用 ActiveJob 调用邮件程序的 Controller 测试现在呈现冗长的警告消息。
[ActiveJob] [ActionMailer::DeliveryJob] [6d2ec032-eff2-40d3-bad4-3b23de65d9bd] Could not log "render_template.action_view" event. NoMethodError: undefined method 'example_group' for nil:NilClass [
"rails/view_rendering.rb:67:in 'current_example_group'", "rspec/rails/view_rendering.rb:71:in 'render_template'", "active_support/subscriber.rb:99:in 'finish'",
... LIST SHORTENED FOR CLARITY ...
"active_job/execution.rb:20:in 'execute'",
... LIST SHORTENED ...
"concurrent/executor/ruby_thread_pool_executor.rb:319:in 'block in create_worker'" ]
Rails 5.1 对发送电子邮件的测试 (API) Controller 进行了哪些更改?我做错了什么吗?
describe Api::UsersController do
it 'creates a new user' do
# THIS ENDPOINT CALLS
# UserMailer.welcome_email(user).deliver_later
post :create, params: params
end
end
最佳答案
我遇到了同样的问题并且使用的是 rspec-rails 3.6.0
。我已降级回 3.5.0
,这为我解决了这个问题。
关于ruby-on-rails - Controller 测试在 Rails 5.1 升级后发出调试(失败)消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43983466/