Skip to content

Commit fc30ff1

Browse files
committed
Add an additional test for nested HAML/ERB/components
1 parent a6d075c commit fc30ff1

File tree

7 files changed

+23
-0
lines changed

7 files changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
%span.bar
2+
= render "haml_partial"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# frozen_string_literal: true
2+
3+
class PartialHamlComponent < ViewComponent::Base
4+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<article class="quux">
2+
What's up!
3+
<%= render HamlComponent.new(message: "It works!") %>
4+
</article>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.baz
2+
= "Heyyy!"
3+
= render "erb_partial"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%p.foo
2+
= "Hello, world!"
3+
= render(PartialHamlComponent.new)

test/sandbox/config/routes.rb

+1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
get :render_component, to: "integration_examples#render_component"
2121
get :controller_inline_render_component, to: "integration_examples#controller_inline_render_component"
2222
get :controller_to_string_render_component, to: "integration_examples#controller_to_string_render_component"
23+
get :nested_haml, to: "integration_examples#nested_haml"
2324
end

test/view_component/integration_test.rb

+6
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,12 @@ def test_returns_404_when_preview_does_not_exist
553553
end
554554
end
555555

556+
def test_renders_a_mix_of_haml_and_erb
557+
get "/nested_haml"
558+
assert_response :success
559+
assert_select "p.foo > span.bar > div.baz > article.quux > div.haml-div"
560+
end
561+
556562
def test_raises_an_error_if_the_template_is_not_present_and_the_render_with_template_method_is_used_in_the_example
557563
error =
558564
assert_raises ViewComponent::PreviewTemplateError do

0 commit comments

Comments
 (0)