class Capybara::Queries::CurrentPathQuery
Public Class Methods
new(expected_path, options = {})
click to toggle source
Calls superclass method
Capybara::Queries::BaseQuery.new
# File lib/capybara/queries/current_path_query.rb, line 7 def initialize(expected_path, options = {}) super(options) @expected_path = expected_path @options = { url: false, only_path: false }.merge(options) assert_valid_keys end
Public Instance Methods
failure_message()
click to toggle source
# File lib/capybara/queries/current_path_query.rb, line 36 def failure_message failure_message_helper end
negative_failure_message()
click to toggle source
# File lib/capybara/queries/current_path_query.rb, line 40 def negative_failure_message failure_message_helper(' not') end
resolves_for?(session)
click to toggle source
# File lib/capybara/queries/current_path_query.rb, line 16 def resolves_for?(session) @actual_path = if options[:url] session.current_url else uri = ::Addressable::URI.parse(session.current_url) if options[:only_path] uri.path unless uri.nil? # Ensure the parsed url isn't nil. else uri.request_uri unless uri.nil? # Ensure the parsed url isn't nil. end end if @expected_path.is_a? Regexp @actual_path.match(@expected_path) else ::Addressable::URI.parse(@expected_path) == ::Addressable::URI.parse(@actual_path) end end
Private Instance Methods
assert_valid_keys()
click to toggle source
Calls superclass method
Capybara::Queries::BaseQuery#assert_valid_keys
# File lib/capybara/queries/current_path_query.rb, line 55 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
failure_message_helper(negated = '')
click to toggle source
# File lib/capybara/queries/current_path_query.rb, line 46 def failure_message_helper(negated = '') verb = (@expected_path.is_a?(Regexp))? 'match' : 'equal' "expected #{@actual_path.inspect}#{negated} to #{verb} #{@expected_path.inspect}" end
valid_keys()
click to toggle source
# File lib/capybara/queries/current_path_query.rb, line 51 def valid_keys [:wait, :url, :only_path] end