Skip to content

Commit

Permalink
Prefer match? over match when captures not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Apr 19, 2019
1 parent a9a38f2 commit 555b7b8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/capybara/queries/current_path_query.rb
Expand Up @@ -22,7 +22,7 @@ def resolves_for?(session)
@actual_path = options[:url] ? uri&.to_s : uri&.request_uri

if @expected_path.is_a? Regexp
@actual_path.to_s.match(@expected_path)
@actual_path.to_s.match?(@expected_path)
else
::Addressable::URI.parse(@expected_path) == ::Addressable::URI.parse(@actual_path)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/queries/selector_query.rb
Expand Up @@ -436,7 +436,7 @@ def normalize_ws
def matches_text_regexp?(node, regexp)
text_visible = visible
text_visible = :all if text_visible == :hidden
!!node.text(text_visible, normalize_ws: normalize_ws).match(regexp)
node.text(text_visible, normalize_ws: normalize_ws).match?(regexp)
end

def default_visibility
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/queries/title_query.rb
Expand Up @@ -13,7 +13,7 @@ def initialize(expected_title, **options)
end

def resolves_for?(node)
(@actual_title = node.title).match(@search_regexp)
(@actual_title = node.title).match?(@search_regexp)
end

def failure_message
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/selector.rb
Expand Up @@ -120,7 +120,7 @@

node_filter(:href) do |node, href|
# If not a Regexp it's been handled in the main XPath
(href.is_a?(Regexp) ? node[:href].match(href) : true).tap do |res|
(href.is_a?(Regexp) ? node[:href].match?(href) : true).tap do |res|
add_error "Expected href to match #{href.inspect} but it was #{node[:href].inspect}" unless res
end
end
Expand Down

0 comments on commit 555b7b8

Please sign in to comment.