Skip to content

Commit ad40aae

Browse files
committed
Only attach LogSubscriber for Rails::ViewRendering when needed
e.g. skip it for feature specs
1 parent bfa6c3f commit ad40aae

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/rspec/rails/view_rendering.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ def render_template(_event)
7777
end
7878
end
7979

80-
LogSubscriber.attach_to(:action_view)
81-
8280
# Delegates all methods to the submitted resolver and for all methods
8381
# that return a collection of `ActionView::Template` instances, return
8482
# templates with modified source
@@ -150,6 +148,9 @@ def _path_decorator(*paths)
150148
end
151149

152150
included do
151+
# Make sure to log when template rendering was prevented by rspec-rails
152+
EmptyTemplateResolver::LogSubscriber.attach_to(:action_view)
153+
153154
before do
154155
unless render_views?
155156
@_original_path_set = controller.class.view_paths

0 commit comments

Comments
 (0)