我正在使用 Rails 5.0.0.beta3,一切正常,在我集成 sendgrid-rails 后,我在运行时遇到了这个异常rspec
There was an error while trying to load the gem 'sendgrid-rails'. (Bundler::GemRequireError)
Gem Load Error is: uninitialized constant AbstractController::Rendering
Backtrace for gem load error is:
/Users/hieupham/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.beta3/lib/action_controller/base.rb:204:in `<class:Base>'
/Users/hieupham/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.beta3/lib/action_controller/base.rb:164:in `<module:ActionController>'
/Users/hieupham/.rvm/gems/ruby-2.3.0/gems/actionpack-5.0.0.beta3/lib/action_controller/base.rb:5:in `<top (required)>'
/Users/hieupham/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.beta3/lib/action_view/test_case.rb:11:in `<class:TestCase>'
/Users/hieupham/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.beta3/lib/action_view/test_case.rb:10:in `<module:ActionView>'
/Users/hieupham/.rvm/gems/ruby-2.3.0/gems/actionview-5.0.0.beta3/lib/action_view/test_case.rb:8:in `<top (required)>'
/Users/hieupham/.rvm/gems/ruby-2.3.0/gems/rails-controller-testing-0.1.1/lib/rails-controller-testing.rb:16:in `block in <top (required)>'
/Users/hieupham/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.beta3/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/Users/hieupham/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.beta3/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/Users/hieupham/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.beta3/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
我认为这只发生在 Rails 5 上,您对此类问题有任何经验吗?
如何解决这个问题?顺便说一句,我也为作者提出了一个问题
谢谢
我刚刚通过以下方式解决了这个问题:
将require false
添加到宝石文件
group :test do
gem 'rails-controller-testing', :require => false
end
要求宝石在test_helper.rb
或rails_helper.rb
之后
# Other configs
require 'rails-controller-testing'
参考此建议