File tree 2 files changed +14
-5
lines changed 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -20,10 +20,6 @@ module RenderLiteralHelpers
20
20
(send nil? {:render :render_to_string} ({str sym} $_) $...)
21
21
PATTERN
22
22
23
- def_node_matcher :render_inst? , <<-PATTERN
24
- (send nil? {:render :render_to_string} (send _ :new ...) ...)
25
- PATTERN
26
-
27
23
def_node_matcher :render_with_options? , <<-PATTERN
28
24
(send nil? {:render :render_to_string} (hash $...) ...)
29
25
PATTERN
@@ -32,6 +28,10 @@ module RenderLiteralHelpers
32
28
(send nil? {:render :render_to_string} (send _ :new ...) ...)
33
29
PATTERN
34
30
31
+ def_node_matcher :render_view_component_instance_with_content? , <<-PATTERN
32
+ (send nil? {:render :render_to_string} (send (send _ :new ...) `:with_content ...))
33
+ PATTERN
34
+
35
35
def_node_matcher :render_view_component_collection? , <<-PATTERN
36
36
(send nil? {:render :render_to_string} (send _ :with_collection ...) ...)
37
37
PATTERN
@@ -45,7 +45,8 @@ def hash_with_literal_keys?(hash)
45
45
end
46
46
47
47
def render_view_component? ( node )
48
- render_view_component_instance? ( node ) ||
48
+ render_view_component_instance_with_content? ( node ) ||
49
+ render_view_component_instance? ( node ) ||
49
50
render_view_component_collection? ( node )
50
51
end
51
52
end
Original file line number Diff line number Diff line change @@ -62,6 +62,14 @@ def test_render_component_instance_no_offense
62
62
assert_equal 0 , cop . offenses . count
63
63
end
64
64
65
+ def test_render_component_instance_with_content_no_offense
66
+ erb_investigate cop , <<-ERB , "app/views/foo/index.html.erb"
67
+ <%= render MyClass . new ( title : "foo" , bar : "baz" ) . with_content ( "foo" ) %>
68
+ ERB
69
+
70
+ assert_equal 0 , cop . offenses . count
71
+ end
72
+
65
73
def test_render_component_instance_block_no_offense
66
74
erb_investigate cop , <<-ERB , "app/views/foo/index.html.erb"
67
75
<%= render Module ::MyClass . new ( title : "foo" , bar : "baz" ) do %> Content<% end %>
You can’t perform that action at this time.
0 commit comments