Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is how you can assert a number of things about a link using <code>assert_select</code>. The 2nd argument can either be a String or a Regexp to test the href attribute against:</p> <pre><code> # URL string (2nd arg) is compared to the href attribute thanks to the '?' in # CSS selector string. Also asserts that there is only one link matching # the arguments (:count option) and that the link has the text # 'Your Dashboard' (:text option) assert_select '.menu a[href=?]', 'http://test.host/dashboard', { :count =&gt; 1, :text =&gt; 'Your Dashboard' } # Regular expression (2nd arg) tests the href attribute thanks to the '?' in # the CSS selector string. assert_select '.menu a[href=?]', /\Ahttp:\/\/test.host\/dashboard\z/, { :count =&gt; 1, :text =&gt; 'Your Dashboard' } </code></pre> <p>For other ways you can use <code>assert_select</code>, here are the examples taken from the Rails actionpack 3.2.15 docs (see file <code>actionpack-3.2.15/lib/action_dispatch/testing/assertions/selector.rb</code>):</p> <pre><code> # At least one form element assert_select "form" # Form element includes four input fields assert_select "form input", 4 # Page title is "Welcome" assert_select "title", "Welcome" # Page title is "Welcome" and there is only one title element assert_select "title", {:count =&gt; 1, :text =&gt; "Welcome"}, "Wrong title or more than one title element" # Page contains no forms assert_select "form", false, "This page must contain no forms" # Test the content and style assert_select "body div.header ul.menu" # Use substitution values assert_select "ol&gt;li#?", /item-\d+/ # All input fields in the form have a name assert_select "form input" do assert_select "[name=?]", /.+/ # Not empty end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload