Skip to content

Commit

Permalink
Use preprend_view_path on all versions of Rails
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Nov 21, 2023
1 parent 9b80d52 commit 52898ce
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions lib/rspec/rails/example/view_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 52898ce

Please sign in to comment.