aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/testing')
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/selector.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb
index 43eb899348..6aa4fea4f2 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/selector.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -191,18 +191,16 @@ module ActionDispatch
text = match.text
text.strip! unless NO_STRIP.include?(match.name)
text.sub!(/\A\n/, '') if match.name == "textarea"
- unless content_matches?(match_with, text)
- content_mismatch ||= sprintf("<%s> expected but was\n<%s>.", match_with, text)
- true
+ content_matches?(match_with, text) do |error_message|
+ content_mismatch ||= error_message
end
end
elsif match_with = equals[:html]
matches.delete_if do |match|
- html = match.children.map(&:to_s).join
+ html = match.to_s
html.strip! unless NO_STRIP.include?(match.name)
- unless content_matches?(match_with, html)
- content_mismatch ||= sprintf("<%s> expected but was\n<%s>.", match_with, html)
- true
+ content_matches?(match_with, html) do |error_message|
+ content_mismatch ||= error_message
end
end
end
@@ -352,6 +350,7 @@ module ActionDispatch
else
content == match_with.to_s
end
+ yield sprintf("<%s> expected but was\n<%s>.", match_with, content) if block_given?
end
class Selector #:nodoc: