From 9893a2896bbde50205e850b616ca0d4d196b924d Mon Sep 17 00:00:00 2001 From: Timm Date: Mon, 22 Jul 2013 22:25:23 +0200 Subject: Changed early return for filter_matches as well as reassigning matches. Meddled with initialize in ArgumentFilter. --- .../lib/action_dispatch/testing/assertions/selector.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'actionpack/lib/action_dispatch/testing/assertions/selector.rb') 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 -- cgit v1.2.3