From 5169b00330584f88a109f12cdc334219114e7c5e Mon Sep 17 00:00:00 2001 From: Timm Date: Fri, 16 Aug 2013 22:22:22 +0200 Subject: Extracted: create Regexp from match_with and use =~ to compare instead of checking .is_a? Regexp every time through the loop. --- actionview/lib/action_view/testing/assertions/selector.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionview/lib/action_view/testing/assertions') diff --git a/actionview/lib/action_view/testing/assertions/selector.rb b/actionview/lib/action_view/testing/assertions/selector.rb index b53e0c1b55..fea07b2897 100644 --- a/actionview/lib/action_view/testing/assertions/selector.rb +++ b/actionview/lib/action_view/testing/assertions/selector.rb @@ -333,6 +333,7 @@ module ActionView content_mismatch = nil text_matches = equality_tests.has_key?(:text) + match_with = Regexp.new(match_with.to_s) unless match_with.is_a?(Regexp) remaining = matches.reject do |match| # Preserve markup with to_s for html elements @@ -341,7 +342,7 @@ module ActionView content.strip! unless NO_STRIP.include?(match.name) content.sub!(/\A\n/, '') if text_matches && match.name == "textarea" - next if match_with.is_a?(Regexp) ? (content =~ match_with) : (content == match_with.to_s) + next if content =~ match_with content_mismatch ||= sprintf("<%s> expected but was\n<%s>.", match_with, content) true end -- cgit v1.2.3