diff --git a/lib/rspec/rails/example/view_example_group.rb b/lib/rspec/rails/example/view_example_group.rb index 43eddb927..a03b19958 100644 --- a/lib/rspec/rails/example/view_example_group.rb +++ b/lib/rspec/rails/example/view_example_group.rb @@ -83,26 +83,14 @@ def view _view end - if ::Rails.version.to_f >= 7.1 - # Simulates the presence of a template on the file system by adding a - # Rails' FixtureResolver to the front of the view_paths list. Designed to - # help isolate view examples from partials rendered by the view template - # that is the subject of the example. - # - # stub_template("widgets/_widget.html.erb" => "This content.") - def stub_template(hash) - controller.prepend_view_path(StubResolverCache.resolver_for(hash)) - end - else - # Simulates the presence of a template on the file system by adding a - # Rails' FixtureResolver to the front of the view_paths list. Designed to - # help isolate view examples from partials rendered by the view template - # that is the subject of the example. - # - # stub_template("widgets/_widget.html.erb" => "This content.") - def stub_template(hash) - view.view_paths.unshift(StubResolverCache.resolver_for(hash)) - end + # Simulates the presence of a template on the file system by adding a + # Rails' FixtureResolver to the front of the view_paths list. Designed to + # help isolate view examples from partials rendered by the view template + # that is the subject of the example. + # + # stub_template("widgets/_widget.html.erb" => "This content.") + def stub_template(hash) + controller.prepend_view_path(StubResolverCache.resolver_for(hash)) end # Provides access to the params hash that will be available within the