aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing
diff options
context:
space:
mode:
authorTimm <kaspth@gmail.com>2013-07-20 13:00:36 +0200
committerTimm <kaspth@gmail.com>2014-06-15 23:40:57 +0200
commit6fa3af8876a12b21871bf6e5fa45ca041d8ae235 (patch)
tree93031b9c8636a0b4446e0b1235137337d75b7f5e /actionpack/lib/action_dispatch/testing
parentcb215c9f7d9e4a9d469abdbd87c0dd909161db95 (diff)
downloadrails-6fa3af8876a12b21871bf6e5fa45ca041d8ae235.tar.gz
rails-6fa3af8876a12b21871bf6e5fa45ca041d8ae235.tar.bz2
rails-6fa3af8876a12b21871bf6e5fa45ca041d8ae235.zip
Removed more lines of code in assert_select.
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: