Class: Capybara::Queries::CurrentPathQuery Private

Inherits:
BaseQuery
  • Object
show all
Defined in:
lib/capybara/queries/current_path_query.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary

Constants inherited from BaseQuery

BaseQuery::COUNT_KEYS

Instance Attribute Summary

Attributes inherited from BaseQuery

#options

Instance Method Summary collapse

Methods inherited from BaseQuery

#wait

Constructor Details

#initialize(expected_path, options = {}) ⇒ CurrentPathQuery

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CurrentPathQuery.



7
8
9
10
11
12
13
# File 'lib/capybara/queries/current_path_query.rb', line 7

def initialize(expected_path, options = {})
  @expected_path = expected_path
  @options = {
    url: false,
    only_path: false }.merge(options)
  assert_valid_keys
end

Instance Method Details

#failure_messageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
# File 'lib/capybara/queries/current_path_query.rb', line 33

def failure_message
  failure_message_helper
end

#negative_failure_messageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
# File 'lib/capybara/queries/current_path_query.rb', line 37

def negative_failure_message
  failure_message_helper(' not')
end

#resolves_for?(session) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/capybara/queries/current_path_query.rb', line 15

def resolves_for?(session)
  @actual_path = if options[:url]
    session.current_url
  else
    if options[:only_path]
      ::Addressable::URI.parse(session.current_url).path
    else
      ::Addressable::URI.parse(session.current_url).request_uri
    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