rspec-rails: NoMethodError: undefined method `example_group' for nil:NilClass
I’m not sure what’s triggering this, yet.
# @private
class LogSubscriber < ::ActiveSupport::LogSubscriber
def current_example_group
RSpec.current_example.example_group
end
def render_template(_event)
return if current_example_group.render_views?
info(" Template rendering was prevented by rspec-rails. Use `render_views` to verify rendered view contents if necessary.")
end
end
[127.0.0.1] [bc765ac7-e5e6-4d8f-894f-707b2ce4b309] Rendered layouts/authentication.html.haml (17.1ms)
[127.0.0.1] [bc765ac7-e5e6-4d8f-894f-707b2ce4b309] Could not log "render_template.action_view" event. NoMethodError: undefined method `render_views?' for RSpec::ExampleGroups::OAuth2Authorization:Class
Could not log "render_template.action_view" event. NoMethodError: undefined method `example_group' for nil:NilClass
[
"/Users/kain/.rvm/gems/ruby-2.4.1/gems/rspec-rails-3.6.0.beta2/lib/rspec/rails/view_rendering.rb:67:in `current_example_group'",
"/Users/kain/.rvm/gems/ruby-2.4.1/gems/rspec-rails-3.6.0.beta2/lib/rspec/rails/view_rendering.rb:71:in `render_template'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/activesupport/lib/active_support/subscriber.rb:95:in `finish'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/activesupport/lib/active_support/log_subscriber.rb:83:in `finish'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/activesupport/lib/active_support/notifications/fanout.rb:102:in `finish'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/activesupport/lib/active_support/notifications/fanout.rb:46:in `block in finish'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/activesupport/lib/active_support/notifications/fanout.rb:46:in `each'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/activesupport/lib/active_support/notifications/fanout.rb:46:in `finish'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/activesupport/lib/active_support/notifications/instrumenter.rb:42:in `finish_with_state'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/activesupport/lib/active_support/notifications/instrumenter.rb:27:in `instrument'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/activesupport/lib/active_support/notifications.rb:164:in `instrument'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionview/lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionview/lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionview/lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionview/lib/action_view/renderer/template_renderer.rb:52:in `render_template'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionview/lib/action_view/renderer/template_renderer.rb:14:in `render'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionview/lib/action_view/renderer/renderer.rb:42:in `render_template'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionview/lib/action_view/renderer/renderer.rb:23:in `render'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionview/lib/action_view/rendering.rb:104:in `_render_template'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionpack/lib/action_controller/metal/streaming.rb:217:in `_render_template'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionview/lib/action_view/rendering.rb:83:in `render_to_body'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionpack/lib/action_controller/metal/rendering.rb:52:in `render_to_body'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionpack/lib/action_controller/metal/renderers.rb:142:in `render_to_body'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionpack/lib/abstract_controller/rendering.rb:26:in `render'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionpack/lib/action_controller/metal/rendering.rb:36:in `render'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionpack/lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/activesupport/lib/active_support/core_ext/benchmark.rb:12:in `block in ms'",
"/Users/kain/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/benchmark.rb:308:in `realtime'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/activesupport/lib/active_support/core_ext/benchmark.rb:12:in `ms'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionpack/lib/action_controller/metal/instrumentation.rb:44:in `block in render'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionpack/lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/activerecord/lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'",
"/Users/kain/.rvm/gems/ruby-2.4.1/bundler/gems/rails-ec9b4d39108d/actionpack/lib/action_controller/metal/instrumentation.rb:43:in `render'",
"/Users/kain/.rvm/gems/ruby-2.4.1/gems/high_voltage-3.0.0/app/controllers/concerns/high_voltage/static_page.rb:19:in `show'",
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 15
- Comments: 19 (8 by maintainers)
Commits related to this issue
- Add repro spec for #1800 — committed to rspec/rspec-rails by yujinakayama 7 years ago
- Update rspec-rails and lock to 3.5 Locked to 3.5 due to an issue in 3.6.0 in which certain specs cause errors to be printed to the logs, making them hard to read. (See https://github.com/rspec/rspec-... — committed to neilvanbeinum/e-petitions by neilvanbeinum 7 years ago
- Update rspec-rails and lock to 3.5 Locked to 3.5 due to an issue in 3.6.0 in which certain specs cause errors to be printed to the logs, making them hard to read. (See https://github.com/rspec/rspec-... — committed to neilvanbeinum/e-petitions by neilvanbeinum 7 years ago
- Update rspec-rails and lock to 3.5 Locked to 3.5 due to an issue in 3.6.0 in which certain specs cause errors to be printed to the logs, making them hard to read. (See https://github.com/rspec/rspec-... — committed to neilvanbeinum/e-petitions by neilvanbeinum 7 years ago
- Pin rspec-rails to 3.5.x Features have noisy errors in logs making them hard to read (see https://github.com/rspec/rspec-rails/issues/1800) — committed to wearefuturegov/total_transport by pezholio 7 years ago
I can confirm that this is also an issue in my application. With rspec 3.6.0, I get
undefined method render_views?, but not with 3.5.4.I was using
config.infer_spec_type_from_file_location!, but disabling that and explicitly addingtype: :featuredoesn’t change anything.I am getting this also.
deliver_later)Hope that helps - I am still not sure what the issue is. I started seeing the issue after the Rails 5.1 upgrade.
@samphippen I think you’ll be able to see the error by adding the following line to your
config/environments/test.rb:This is an app that reproduces the issue: github.com/lucascaton/rspec-rails-issue-1800.
@lucascaton @marktran @masterkain Thanks for the issue. We need a little more detail to be able to reproduce this.
Could you please provide us with a rails app that we can clone that demonstrates the issue. Specifically it’d be great if
rails newan application and committhen, provide us with a description of how to clone your application and reproduce the issue.
Thanks 😃