Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions test/erb/test_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,65 @@ def test_format_ruby_with_long_lines_and_larger_line_width
)
end

def test_format_ruby_with_block
input = <<~ERB.chomp
<%=
render FooComponent.new(title: t('.page_title')) do |c|
c.with_body.with_content(t('.intro_html'))
end
%>
ERB

expected_output = <<~ERB.chomp
<%= render FooComponent.new(title: t(".page_title")) do |c|
c.with_body.with_content(t(".intro_html"))
end %>
ERB

assert_equal(expected_output, ERB::Formatter.format(input).strip)
end

def test_format_ruby_with_block_with_parantheses
input = <<~ERB.chomp
<%=
render(FooComponent.new(title: t('.page_title')) do |c|
c.with_body.with_content(t('.intro_html'))
end)
%>
ERB

expected_output = <<~ERB.chomp
<%= render(
FooComponent.new(title: t(".page_title")) do |c|
c.with_body.with_content(t(".intro_html"))
end,
) %>
ERB

assert_equal(expected_output, ERB::Formatter.format(input).strip)
end

def test_format_ruby_with_block_with_variable
input = <<~ERB.chomp
<%=
component = FooComponent.new(title: t('.page_title')) do |c|
c.with_body.with_content(t('.intro_html'))
end
render component
%>
ERB

expected_output = <<~ERB.chomp
<%= component =
FooComponent.new(title: t(".page_title")) do |c|
c.with_body.with_content(t(".intro_html"))
end
render component %>
ERB

assert_equal(expected_output, ERB::Formatter.format(input).strip)
end

def test_tailwindcss_class_sorting
require 'tailwindcss-rails'
require 'erb/formatter/command_line'
Expand Down