Skip to content

Commit 1429d15

Browse files
authored
Engine: Add more tests for left and right ERB Trimming (marcoroth#650)
More tests for marcoroth#649 and marcoroth#841.
1 parent b001fed commit 1429d15

19 files changed

+75
-9
lines changed

examples/left-right-trim.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<%- if true -%>
2+
<h1>Content</h1>
3+
<%- end -%>

examples/left-trim.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<%- if true %>
2+
<h1>Content</h1>
3+
<%- end %>

examples/right-trim.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<% if true -%>
2+
<h1>Content</h1>
3+
<% end -%>

test/engine/evaluation_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,5 +434,23 @@ class EvaluationTest < Minitest::Spec
434434

435435
assert_evaluated_snapshot(template, { more: "ignored" }, { escape: false })
436436
end
437+
438+
test "left trim" do
439+
template = File.read("examples/left-trim.html.erb")
440+
441+
assert_evaluated_snapshot(template, {}, { escape: false })
442+
end
443+
444+
test "right trim" do
445+
template = File.read("examples/right-trim.html.erb")
446+
447+
assert_evaluated_snapshot(template, {}, { escape: false })
448+
end
449+
450+
test "left and right trim" do
451+
template = File.read("examples/left-right-trim.html.erb")
452+
453+
assert_evaluated_snapshot(template, {}, { escape: false })
454+
end
437455
end
438456
end

test/snapshots/engine/evaluation_test/test_0031_left_trim_0487ac667a435a75abae76d26bc3184c.txt

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/snapshots/engine/evaluation_test/test_0032_right_trim_009d413f1066d04acea88ea6ff36cbe2.txt

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/snapshots/engine/evaluation_test/test_0033_left_and_right_trim_1ab048e2a4ad2c02bdd61e558180d866.txt

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/snapshots/engine/examples_compilation_test/test_0015_left_right_trim_compilation_0416edce0119986c84ba03c645b50717.txt

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/snapshots/engine/examples_compilation_test/test_0016_left_trim_compilation_12bf92840853103be656f8d585205a84.txt

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/snapshots/engine/examples_compilation_test/test_0015_line_wrap_compilation_ba78b92bec7a4692a2043f2ba2ebe057.txt renamed to test/snapshots/engine/examples_compilation_test/test_0017_line_wrap_compilation_ba78b92bec7a4692a2043f2ba2ebe057.txt

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)