From 52898cebb233d5d6f5f8f4c3b3d40b16bc6d04c8 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 21 Nov 2023 08:46:28 +0000 Subject: [PATCH] Use preprend_view_path on all versions of Rails --- lib/rspec/rails/example/view_example_group.rb | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) 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