It looks like some misunderstanding with terms.
CSS-selectors are patterns used to select the element(s) you want to style. And assert_select
is used for selectors testing (not only for <select>
elements).
There is the link in your question to Rails Guide. From there:
The assert_select
method allows you to query HTML elements of the response by using a simple yet powerful syntax.
There are two forms of assert_select
:
assert_select(selector, [equality], [message])
ensures that the equality condition is met on the selected elements through the selector. The selector may be a CSS selector expression (String) or an expression with substitution values.
assert_select(element, selector, [equality], [message])
ensures that the equality condition is met on all the selected elements through the selector starting from the element (instance of Nokogiri::XML::Node or Nokogiri::XML::NodeSet
) and its descendants.
For example, you could verify the contents on the title element in your response with:
assert_select 'title', "Welcome to Rails Testing Guide"
You can also use nested assert_select
blocks for deeper investigation.
In the following example, the inner assert_select
for li.menu_item
runs within the collection of elements selected by the outer block:
assert_select 'ul.navigation' do
assert_select 'li.menu_item'
end