Skip to content

Commit 52898ce

Browse files
committed
Use preprend_view_path on all versions of Rails
1 parent 9b80d52 commit 52898ce

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

lib/rspec/rails/example/view_example_group.rb

+8-20
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,14 @@ def view
8383
_view
8484
end
8585

86-
if ::Rails.version.to_f >= 7.1
87-
# Simulates the presence of a template on the file system by adding a
88-
# Rails' FixtureResolver to the front of the view_paths list. Designed to
89-
# help isolate view examples from partials rendered by the view template
90-
# that is the subject of the example.
91-
#
92-
# stub_template("widgets/_widget.html.erb" => "This content.")
93-
def stub_template(hash)
94-
controller.prepend_view_path(StubResolverCache.resolver_for(hash))
95-
end
96-
else
97-
# Simulates the presence of a template on the file system by adding a
98-
# Rails' FixtureResolver to the front of the view_paths list. Designed to
99-
# help isolate view examples from partials rendered by the view template
100-
# that is the subject of the example.
101-
#
102-
# stub_template("widgets/_widget.html.erb" => "This content.")
103-
def stub_template(hash)
104-
view.view_paths.unshift(StubResolverCache.resolver_for(hash))
105-
end
86+
# Simulates the presence of a template on the file system by adding a
87+
# Rails' FixtureResolver to the front of the view_paths list. Designed to
88+
# help isolate view examples from partials rendered by the view template
89+
# that is the subject of the example.
90+
#
91+
# stub_template("widgets/_widget.html.erb" => "This content.")
92+
def stub_template(hash)
93+
controller.prepend_view_path(StubResolverCache.resolver_for(hash))
10694
end
10795

10896
# Provides access to the params hash that will be available within the

0 commit comments

Comments
 (0)