Class: Capybara::Queries::TextQuery Private
- Defined in:
- lib/capybara/queries/text_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
Instance Attribute Summary
Attributes inherited from BaseQuery
Instance Method Summary collapse
- #description ⇒ Object private
- #failure_message ⇒ Object private
-
#initialize(type = nil, expected_text, session_options:, **options) ⇒ TextQuery
constructor
private
rubocop:disable Style/OptionalArguments.
- #negative_failure_message ⇒ Object private
- #resolve_for(node) ⇒ Object private
Methods inherited from BaseQuery
#expects_none?, #matches_count?, wait, #wait
Constructor Details
#initialize(type = nil, expected_text, session_options:, **options) ⇒ TextQuery
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.
rubocop:disable Style/OptionalArguments
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/capybara/queries/text_query.rb', line 7 def initialize(type = nil, expected_text, session_options:, **) # rubocop:disable Style/OptionalArguments @type = type.nil? ? default_type : type raise ArgumentError, "#{@type} is not a valid type for a text query" unless valid_types.include?(@type) @options = super(@options) self. = if expected_text.nil? && !exact? warn 'Checking for expected text of nil is confusing and/or pointless since it will always match. ' \ "Please specify a string or regexp instead. #{Capybara::Helpers.filter_backtrace(caller)}" end @expected_text = expected_text.is_a?(Regexp) ? expected_text : expected_text.to_s @search_regexp = Capybara::Helpers.to_regexp(@expected_text, exact: exact?) assert_valid_keys end |
Instance Method Details
#description ⇒ Object
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.
41 42 43 44 45 46 47 |
# File 'lib/capybara/queries/text_query.rb', line 41 def description if @expected_text.is_a?(Regexp) "text matching #{@expected_text.inspect}" else "#{'exact ' if exact?}text #{@expected_text.inspect}" end end |
#failure_message ⇒ Object
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/text_query.rb', line 33 def super << (true) end |
#negative_failure_message ⇒ Object
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/text_query.rb', line 37 def super << (false) end |
#resolve_for(node) ⇒ Object
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.
27 28 29 30 31 |
# File 'lib/capybara/queries/text_query.rb', line 27 def resolve_for(node) @node = node @actual_text = text @count = @actual_text.scan(@search_regexp).size end |