aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing/assertions/selector.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-01-06 11:48:32 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-01-06 11:48:32 -0800
commit6548fc66178dd3d46e3a575e6937659c07293764 (patch)
treeaa8ab3dc59eb5619b333a7fc1b4d23691cee8a42 /actionpack/lib/action_dispatch/testing/assertions/selector.rb
parenta0dc9cae88cd98ccd9ce6788237c6d0855bbf119 (diff)
downloadrails-6548fc66178dd3d46e3a575e6937659c07293764.tar.gz
rails-6548fc66178dd3d46e3a575e6937659c07293764.tar.bz2
rails-6548fc66178dd3d46e3a575e6937659c07293764.zip
use assert_equal and assert_operator
Diffstat (limited to 'actionpack/lib/action_dispatch/testing/assertions/selector.rb')
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/selector.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb
index b4555f4f59..4d963803e6 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/selector.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -270,7 +270,7 @@ module ActionDispatch
end
text.strip! unless NO_STRIP.include?(match.name)
unless match_with.is_a?(Regexp) ? (text =~ match_with) : (text == match_with.to_s)
- content_mismatch ||= build_message(message, "<?> expected but was\n<?>.", match_with, text)
+ content_mismatch ||= sprintf("<%s> expected but was\n<%s>.", match_with, text)
true
end
end
@@ -279,7 +279,7 @@ module ActionDispatch
html = match.children.map(&:to_s).join
html.strip! unless NO_STRIP.include?(match.name)
unless match_with.is_a?(Regexp) ? (html =~ match_with) : (html == match_with.to_s)
- content_mismatch ||= build_message(message, "<?> expected but was\n<?>.", match_with, html)
+ content_mismatch ||= sprintf("<%s> expected but was\n<%s>.", match_with, html)
true
end
end
@@ -289,12 +289,15 @@ module ActionDispatch
message ||= content_mismatch if matches.empty?
# Test minimum/maximum occurrence.
min, max, count = equals[:minimum], equals[:maximum], equals[:count]
+
+ # FIXME: minitest provides messaging when we use assert_operator,
+ # so is this custom message really needed?
message = message || %(Expected #{count_description(min, max, count)} matching "#{selector.to_s}", found #{matches.size}.)
if count
- assert matches.size == count, message
+ assert_equal matches.size, count, message
else
- assert matches.size >= min, message if min
- assert matches.size <= max, message if max
+ assert_operator matches.size, :>=, min, message if min
+ assert_operator matches.size, :<=, max, message if max
end
# If a block is given call that block. Set @selected to allow