Class: Capybara::Queries::StyleQuery Private

Inherits:
BaseQuery
  • Object
show all
Defined in:
lib/capybara/queries/style_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, #session_options

Instance Method Summary collapse

Methods inherited from BaseQuery

#expects_none?, #matches_count?, #negative_failure_message, wait, #wait

Constructor Details

#initialize(expected_styles, session_options:, **options) ⇒ StyleQuery

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 StyleQuery.

 7 8 9 10 11 12 13 14 15
# File 'lib/capybara/queries/style_query.rb', line 7 def initialize(expected_styles, session_options:, **options) @expected_styles = stringify_keys(expected_styles) @options = options @actual_styles = {} super(@options) self.session_options = session_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.

 29 30 31 32
# File 'lib/capybara/queries/style_query.rb', line 29 def failure_message "Expected node to have styles #{@expected_styles.inspect}. " \ "Actual styles were #{@actual_styles.inspect}" end

#resolves_for?(node) ⇒ 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)
 17 18 19 20 21 22 23 24 25 26 27
# File 'lib/capybara/queries/style_query.rb', line 17 def resolves_for?(node) @node = node @actual_styles = node.style(*@expected_styles.keys) @expected_styles.all? do |style, value| if value.is_a? Regexp value.match? @actual_styles[style] else @actual_styles[style] == value end end end