Skip to content

Commit 9ab092c

Browse files
committed
Nest private classes under EmptyTemplateResolver
1 parent 790b2cd commit 9ab092c

File tree

1 file changed

+33
-36
lines changed

1 file changed

+33
-36
lines changed

lib/rspec/rails/view_rendering.rb

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,13 @@ def render_views?
4343
class EmptyTemplateResolver
4444
def self.build(path)
4545
if path.is_a?(::ActionView::Resolver)
46-
EmptyTemplateResolverDecorator.new(path)
46+
ResolverDecorator.new(path)
4747
else
48-
EmptyTemplateFileSystemResolver.new(path)
48+
FileSystemResolver.new(path)
4949
end
5050
end
51-
end
52-
53-
# Delegates find_templates to the submitted resolver and then returns templates
54-
# with modified source
55-
#
56-
# @private
57-
class EmptyTemplateResolverDecorator
58-
def initialize(resolver)
59-
@resolver = resolver
60-
end
61-
62-
def method_missing(name, *args, &block)
63-
@resolver.send(name, *args, &block)
64-
end
6551

66-
private
67-
68-
def find_templates(*args)
69-
templates = @resolver.find_templates(*args)
52+
def self.nullify_template_rendering(templates)
7053
templates.map do |template|
7154
::ActionView::Template.new(
7255
"",
@@ -77,24 +60,38 @@ def find_templates(*args)
7760
)
7861
end
7962
end
80-
end
8163

82-
# Delegates find_templates to the submitted path set and then returns
83-
# templates with modified source
84-
#
85-
# @private
86-
class EmptyTemplateFileSystemResolver < ::ActionView::FileSystemResolver
87-
private
64+
# Delegates find_templates to the submitted resolver and then returns templates
65+
# with modified source
66+
#
67+
# @private
68+
class ResolverDecorator
69+
def initialize(resolver)
70+
@resolver = resolver
71+
end
8872

89-
def find_templates(*args)
90-
super.map do |template|
91-
::ActionView::Template.new(
92-
"",
93-
template.identifier,
94-
EmptyTemplateHandler,
95-
:virtual_path => template.virtual_path,
96-
:format => template.formats
97-
)
73+
def method_missing(name, *args, &block)
74+
@resolver.send(name, *args, &block)
75+
end
76+
77+
private
78+
79+
def find_templates(*args)
80+
templates = @resolver.find_templates(*args)
81+
EmptyTemplateResolver.nullify_template_rendering(templates)
82+
end
83+
end
84+
85+
# Delegates find_templates to the submitted path set and then returns
86+
# templates with modified source
87+
#
88+
# @private
89+
class FileSystemResolver < ::ActionView::FileSystemResolver
90+
private
91+
92+
def find_templates(*args)
93+
templates = super
94+
EmptyTemplateResolver.nullify_template_rendering(templates)
9895
end
9996
end
10097
end

0 commit comments

Comments
 (0)