diff options
author | Timm <kaspth@gmail.com> | 2013-08-16 22:22:22 +0200 |
---|---|---|
committer | Timm <kaspth@gmail.com> | 2014-06-16 21:04:09 +0200 |
commit | 5169b00330584f88a109f12cdc334219114e7c5e (patch) | |
tree | 816ef384e1ce76caed25ad4f3514c343381b9964 /actionview/lib/action_view | |
parent | e600b3a34116d90b9df5c9bf359e05564999b359 (diff) | |
download | rails-5169b00330584f88a109f12cdc334219114e7c5e.tar.gz rails-5169b00330584f88a109f12cdc334219114e7c5e.tar.bz2 rails-5169b00330584f88a109f12cdc334219114e7c5e.zip |
Extracted: create Regexp from match_with and use =~ to compare instead of checking .is_a? Regexp every time through the loop.
Diffstat (limited to 'actionview/lib/action_view')
-rw-r--r-- | actionview/lib/action_view/testing/assertions/selector.rb | 3 |
1 files changed, 2 insertions, 1 deletions
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 |