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'",
The error your seeing is a symptom of the initial error which is quite subtly mentioned:
NoMethodError: undefined method `render_views?' for RSpec::ExampleGroups::OAuth2Authorization:Class
Likely that example group doesn't have the required type metadata and so breaks causing the later logging error.
it's in spec/features and it's marked with type: :feature, it does not use render views. is this supposed to happen?
@masterkain could you possibly post a snippet of your original spec file? There may be a chance that it doesn't recognise that you are trying to process a view spec.
The metadata or the directory in which your test has been placed in may possibly be causing the issue.
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 adding type: :feature doesn't change anything.
I had the same issue and solved it by replacing RSpec.feature with describe in my specs.
Any news on this?
@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
1) you could rails new an application and commit
2) make all the changes necessary to reproduce the issue and commit
then, provide us with a description of how to clone your application and reproduce the issue.
Thanks :)
@samphippen I think you'll be able to see the error by adding the following line to your config/environments/test.rb:
config.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT))
This is an app that reproduces the issue: github.com/lucascaton/rspec-rails-issue-1800.
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.
The _Needs reproduction case_ label no longer applies since lucascaton offered a rails app and yujinakayama added a repro spec in #1818. Just mentioning this, because it would be nice to get rid of the flood of error messages from test.log.
You guys are all doing awesome work, thanks for that!
Also seeing this on a mailer test in a Rails 5.1 app after upgrading from rspec-rails 3.5.2 to 3.6. Reverting to 3.5.2 for the time being to keep the log at bay.
I've just created #1827 which extends upon #1818 which fixes those errors for me and keeps the logs clean.
In my case the request came via the capybara webdriver and RSpec.current_example is nil then causing the error in the title. @yujinakayama's spec repro in #1818 points to the cause being that FeatureExampleGroup doesn't include RSpec::Rails::ViewRendering while ControllerExampleGroup does. That's why that PR #1732 works for controller specs but it seems to break for feature specs.
To mark Feature spec as Controller spec by :type => :controller like following could avoid this error message. Actually it's indeed Feature spec other than Controller spec, so I think this way is improper:
describe "products page", :type => :controller do
Hope someone could fix this issue by upgrading rspec-rails of version 3.6.0
I'm seeing this error too, in mailer specs under rspec-rails 3.6.0. Under rspec-rails 3.5.2 there is no error. Looks like #1827 has stalled? Is there anything I can do to help?
Hope @aCandidMind and @JonRowe could make progress with [#1827] quickly
I believe #1831 fixes this.
I can confirm that #1831 fixes the issue for me (which I can see on 3.6.0 and on rspec-rails/master)
s/fixes/silences
Closed by #1831
Most helpful comment
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.