/usr/lib/ruby/vendor_ruby/capybara/queries/current_path_query.rb is in ruby-capybara 2.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | module Capybara
# @api private
module Queries
class CurrentPathQuery < BaseQuery
def initialize(expected_path, options = {})
@expected_path = expected_path
@options = {
url: false,
only_path: false }.merge(options)
assert_valid_keys
end
def resolves_for?(session)
@actual_path = if options[:url]
session.current_url
else
if options[:only_path]
URI.parse(session.current_url).path
else
URI.parse(session.current_url).request_uri
end
end
if @expected_path.is_a? Regexp
@actual_path.match(@expected_path)
else
@expected_path == @actual_path
end
end
def failure_message
failure_message_helper
end
def negative_failure_message
failure_message_helper(' not')
end
private
def failure_message_helper(negated = '')
verb = (@expected_path.is_a?(Regexp))? 'match' : 'equal'
"expected #{@actual_path.inspect}#{negated} to #{verb} #{@expected_path.inspect}"
end
def valid_keys
[:wait, :url, :only_path]
end
def assert_valid_keys
super
if options[:url] && options[:only_path]
raise ArgumentError, "the :url and :only_path options cannot both be true"
end
end
end
end
end
|