Method: Capybara::Node::Matchers#assert_matches_style

Defined in:
lib/capybara/node/matchers.rb

#assert_matches_style(styles = nil, **options) ⇒ Object

Asserts that an element has the specified CSS styles.

element.assert_matches_style( 'color' => 'rgb(0,0,255)', 'font-size' => /px/ )

Parameters:

  • styles (Hash) (defaults to: nil)

Raises:



126
127
128
129
130
131
132
133
134
# File 'lib/capybara/node/matchers.rb', line 126

def assert_matches_style(styles = nil, **options)
  styles, options = options, {} if styles.nil?
  query_args, query_opts = _set_query_session_options(styles, options)
  query = Capybara::Queries::StyleQuery.new(*query_args, **query_opts)
  synchronize(query.wait) do
    raise Capybara::ExpectationNotMet, query.failure_message unless query.resolves_for?(self)
  end
  true
end