@@ -82,14 +82,26 @@ def view
82
82
_view
83
83
end
84
84
85
- # Simulates the presence of a template on the file system by adding a
86
- # Rails' FixtureResolver to the front of the view_paths list. Designed to
87
- # help isolate view examples from partials rendered by the view template
88
- # that is the subject of the example.
89
- #
90
- # stub_template("widgets/_widget.html.erb" => "This content.")
91
- def stub_template ( hash )
92
- view . view_paths . unshift ( StubResolverCache . resolver_for ( hash ) )
85
+ if ::Rails . version . to_f >= 7.1
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
+ view . view_paths . send ( :initialize_copy , ActionView ::PathSet . new ( [ StubResolverCache . resolver_for ( hash ) ] + view . view_paths . paths ) )
94
+ end
95
+ else
96
+ # Simulates the presence of a template on the file system by adding a
97
+ # Rails' FixtureResolver to the front of the view_paths list. Designed to
98
+ # help isolate view examples from partials rendered by the view template
99
+ # that is the subject of the example.
100
+ #
101
+ # stub_template("widgets/_widget.html.erb" => "This content.")
102
+ def stub_template ( hash )
103
+ view . view_paths . unshift ( StubResolverCache . resolver_for ( hash ) )
104
+ end
93
105
end
94
106
95
107
# Provides access to the params hash that will be available within the
0 commit comments