我最近將一個項目升級到了Rails 5.1。控制器測試在Rails 5.1升級後發出調試(失敗)消息
- 修正所有棄用警告。
- 通過了所有測試(我用
rspec-rails
) - 控制器測試,使用ActiveJob呼叫郵包現在呈現漫長的警告消息。
[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)控制器?難道我做錯了什麼?
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
這是一個已知問題https://github.com/rspec/rspec-rails/issues/1800 – HarlemSquirrel