123456789_123456789_123456789_123456789_123456789_

Class: Capybara::Queries::TitleQuery Private

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, BaseQuery
Instance Chain:
self, BaseQuery
Inherits: Capybara::Queries::BaseQuery
Defined in: lib/capybara/queries/title_query.rb

Constant Summary

BaseQuery - Inherited

COUNT_KEYS

Class Method Summary

BaseQuery - Inherited

Instance Attribute Summary

BaseQuery - Inherited

#expects_none?

Checks if a count of 0 is valid for the query Returns false if query does not have any count options specified.

#options, #session_options, #session_options=, #count_specified?

Instance Method Summary

BaseQuery - Inherited

#failure_message

Generates a failure message from the query description and count options.

#matches_count?

Checks if the given count matches the query count options.

#negative_failure_message, #wait, #assert_valid_keys, #count_message, #occurrences

Constructor Details

.new(expected_title, **options) ⇒ TitleQuery

[ GitHub ]

  
# File 'lib/capybara/queries/title_query.rb', line 7

def initialize(expected_title, **options)
  @expected_title = expected_title.is_a?(Regexp) ? expected_title : expected_title.to_s
  @options = options
  super(@options)
  @search_regexp = Helpers.to_regexp(@expected_title, all_whitespace: true, exact: options.fetch(:exact, false))
  assert_valid_keys
end

Instance Method Details

#failure_message

[ GitHub ]

  
# File 'lib/capybara/queries/title_query.rb', line 19

def failure_message
  failure_message_helper
end

#failure_message_helper(negated = '') (private)

[ GitHub ]

  
# File 'lib/capybara/queries/title_query.rb', line 29

def failure_message_helper(negated = '')
  verb = @expected_title.is_a?(Regexp) ? 'match' : 'include'
  "expected #{@actual_title.inspect}#{negated} to #{verb} #{@expected_title.inspect}"
end

#negative_failure_message

[ GitHub ]

  
# File 'lib/capybara/queries/title_query.rb', line 23

def negative_failure_message
  failure_message_helper(' not')
end

#resolves_for?(node) ⇒ Boolean

[ GitHub ]

  
# File 'lib/capybara/queries/title_query.rb', line 15

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

#valid_keys (private)

[ GitHub ]

  
# File 'lib/capybara/queries/title_query.rb', line 34

def valid_keys
  %i[wait exact]
end