aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/testing
diff options
context:
space:
mode:
authorTimm <kaspth@gmail.com>2013-07-22 22:25:23 +0200
committerTimm <kaspth@gmail.com>2014-06-15 23:40:59 +0200
commit9893a2896bbde50205e850b616ca0d4d196b924d (patch)
treec7196456a83d2b6761c5c3462bdc16245e974024 /actionpack/lib/action_dispatch/testing
parent7ef141a7fc3bd089a9b8c31e69f702596ae91535 (diff)
downloadrails-9893a2896bbde50205e850b616ca0d4d196b924d.tar.gz
rails-9893a2896bbde50205e850b616ca0d4d196b924d.tar.bz2
rails-9893a2896bbde50205e850b616ca0d4d196b924d.zip
Changed early return for filter_matches as well as reassigning matches. Meddled with initialize in ArgumentFilter.
Diffstat (limited to 'actionpack/lib/action_dispatch/testing')
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/selector.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/testing/assertions/selector.rb b/actionpack/lib/action_dispatch/testing/assertions/selector.rb
index 47e5c8e0e6..7a1176485e 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/selector.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/selector.rb
@@ -166,7 +166,7 @@ module ActionDispatch
matches = filter.root.css(selector)
content_mismatch = nil
- filter_matches(matches, equals) do |mismatch|
+ matches = filter_matches(matches, equals) do |mismatch|
content_mismatch ||= mismatch
end
@@ -295,10 +295,10 @@ module ActionDispatch
protected
def filter_matches(matches, options)
match_with = options[:text] || options[:html]
- return unless match_with
+ return matches unless match_with
text_matches = options.has_key?(:text)
- matches.delete_if do |match|
+ matches.reject do |match|
# Preserve html markup with to_s if not matching text elements
content = text_matches ? match.text : match.to_s
@@ -339,14 +339,14 @@ module ActionDispatch
class ArgumentFilter #:nodoc:
attr_accessor :root, :css_selector, :comparisons, :message
- def initialize(selected, page, *args)
+ def initialize(selected, page, args)
@selected, @page = selected, page
# Start with optional element followed by mandatory selector.
- @root = determine_root_from(args.shift)
+ @root = determine_root_from(args.first)
# First or second argument is the selector
- selector = @css_selector_is_second_argument ? args.shift : args.first
+ selector = @css_selector_is_second_argument ? args.shift(2).last : args.shift
unless selector.is_a? String
raise ArgumentError, "Expecting a selector as the first argument"
end