From d8b12d131c05918d9a3e94b84561c76fad1ef4d4 Mon Sep 17 00:00:00 2001 From: Kazuki Nishikawa Date: Wed, 24 Dec 2025 18:03:03 +0900 Subject: [PATCH 1/2] Add test cases that causes an error in ERB formatting --- spec/lib/rufo/erb_formatter_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/lib/rufo/erb_formatter_spec.rb b/spec/lib/rufo/erb_formatter_spec.rb index 9ad8816c..fca626c6 100644 --- a/spec/lib/rufo/erb_formatter_spec.rb +++ b/spec/lib/rufo/erb_formatter_spec.rb @@ -90,6 +90,16 @@ expect(result).to eql("<%= yield %>") end + it "formats standalone 'yield' with arguments" do + result = subject.format("<%=yield x,y%>") + expect(result).to eql("<%= yield x, y %>") + end + + it "formats standalone 'yield' with arguments and parens" do + result = subject.format("<%=yield(x,y)%>") + expect(result).to eql("<%= yield(x, y) %>") + end + it "handles native erb comments" do result = subject.format("<%# locals: (item:, variant:) %>") expect(result).to eql("<%# locals: (item:, variant:) %>") @@ -99,5 +109,20 @@ result = subject.format("<% # TODO: fix this later %>") expect(result).to eql("<% # TODO: fix this later %>") end + + it 'handles case/when expression' do + result = subject.format(<<~ERB) + <% case a+b %> + <% when c %> + <%= d+e %> + <% end %> + ERB + expect(result).to eql(<<~ERB) + <% case a + b %> + <% when c %> + <%= d + e %> + <% end %> + ERB + end end end From a78ab231b30698a5bb50d5b9c3145388f1de86da Mon Sep 17 00:00:00 2001 From: Kazuki Nishikawa Date: Wed, 24 Dec 2025 18:07:28 +0900 Subject: [PATCH 2/2] format --- spec/lib/rufo/erb_formatter_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/lib/rufo/erb_formatter_spec.rb b/spec/lib/rufo/erb_formatter_spec.rb index fca626c6..8db16d52 100644 --- a/spec/lib/rufo/erb_formatter_spec.rb +++ b/spec/lib/rufo/erb_formatter_spec.rb @@ -110,7 +110,7 @@ expect(result).to eql("<% # TODO: fix this later %>") end - it 'handles case/when expression' do + it "handles case/when expression" do result = subject.format(<<~ERB) <% case a+b %> <% when c %> @@ -118,11 +118,11 @@ <% end %> ERB expect(result).to eql(<<~ERB) - <% case a + b %> - <% when c %> - <%= d + e %> - <% end %> - ERB + <% case a + b %> + <% when c %> + <%= d + e %> + <% end %> + ERB end end end