Skip to content

Commit b2d22e4

Browse files
committed
Check if path is a path before decorating it
When you prepend or append view paths, you can choose to do so with either a path (which may be looked up on the file system) or an instance of `ActionView::Resolver` which will then know how to do the lookup. We should only wrap paths (`String` or `Pathname` instances) in an `EmptyTemplateResolver`.
1 parent 41628f8 commit b2d22e4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/rspec/rails/view_rendering.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def render_views?
3939
self.class.render_views? || !controller.class.respond_to?(:view_paths)
4040
end
4141

42-
# Delegates find_all to the submitted path set and then returns templates
43-
# with modified source
42+
# Delegates find_templates to the submitted path set and then returns
43+
# templates with modified source
4444
#
4545
# @private
4646
class EmptyTemplateResolver < ::ActionView::FileSystemResolver
@@ -81,7 +81,12 @@ def append_view_path(new_path)
8181
private
8282

8383
def _path_decorator(path)
84-
EmptyTemplateResolver.new(path)
84+
case path
85+
when Pathname, String
86+
EmptyTemplateResolver.new(path.to_s)
87+
else
88+
path
89+
end
8590
end
8691
end
8792

0 commit comments

Comments
 (0)