Controller test emits debug (failure) messages after Rails 5.1 upgrade

醉酒当歌 提交于 2019-12-08 00:05:20

问题


I have recently upgraded a project to Rails 5.1.

  • All deprecation warnings were fixed.
  • All tests pass (I use rspec-rails)
  • Controller tests that call mailers using ActiveJob are now rendering lengthy warning messages.

[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'" ]

What has changed in Rails 5.1 for testing (API) controllers that send emails? Am I doing something wrong?

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

回答1:


I had the same problem and was using rspec-rails 3.6.0. I've downgraded back to 3.5.0 which fixed the issue for me.



来源:https://stackoverflow.com/questions/43983466/controller-test-emits-debug-failure-messages-after-rails-5-1-upgrade

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!