mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
The DomAssertions now also strip surrounding whitespace inside tags.
This commit is contained in:
@@ -4,7 +4,8 @@ module ActionController
|
||||
def self.strip_whitespace!(nodes)
|
||||
nodes.reject! do |node|
|
||||
if node.is_a?(HTML::Text)
|
||||
node.to_s.strip.empty?
|
||||
node.content.strip!
|
||||
node.content.empty?
|
||||
else
|
||||
strip_whitespace! node.children
|
||||
false
|
||||
|
||||
@@ -6,8 +6,10 @@ class DomAssertionsTest < ActionView::TestCase
|
||||
@html_only = '<ul><li>foo</li><li>bar</li></ul>'
|
||||
@html_with_meaningless_whitespace = %{
|
||||
<ul>
|
||||
<li>foo</li>
|
||||
<li>bar</li>
|
||||
<li>\tfoo </li>
|
||||
<li>
|
||||
bar
|
||||
</li>
|
||||
</ul>
|
||||
}
|
||||
@more_html_with_meaningless_whitespace = %{<ul>
|
||||
@@ -15,7 +17,6 @@ class DomAssertionsTest < ActionView::TestCase
|
||||
<li>foo</li>
|
||||
|
||||
<li>bar</li></ul>}
|
||||
@html_with_meaningful_whitespace = '<ul><li> foo </li><li> bar </li></ul>'
|
||||
end
|
||||
|
||||
test "assert_dom_equal strips meaningless whitespace from expected string" do
|
||||
@@ -30,12 +31,6 @@ class DomAssertionsTest < ActionView::TestCase
|
||||
assert_dom_equal @more_html_with_meaningless_whitespace, @html_with_meaningless_whitespace
|
||||
end
|
||||
|
||||
test "assert_dom_equal does not strip important whitespace" do
|
||||
assert_assertion_fails do
|
||||
assert_dom_equal @html_with_meaningful_whitespace, @html_only
|
||||
end
|
||||
end
|
||||
|
||||
test "assert_dom_not_equal strips meaningless whitespace from expected string" do
|
||||
assert_assertion_fails { assert_dom_not_equal @html_with_meaningless_whitespace, @html_only }
|
||||
end
|
||||
@@ -50,10 +45,6 @@ class DomAssertionsTest < ActionView::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
test "assert_dom_not_equal does not strip important whitespace" do
|
||||
assert_dom_not_equal @html_with_meaningful_whitespace, @html_only
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_assertion_fails
|
||||
|
||||
Reference in New Issue
Block a user