Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>These are all good suggestions, but if you want to confirm that it's a button and that it has the right value (for display), you have to be a little more detailed:</p> <pre><code>page.should have_selector("input[type=submit][value='Press Me']") </code></pre> <p>I don't know of an existing matcher that does this. Here's a custom RSpec2 matcher I wrote:</p> <pre><code>RSpec::Matchers.define :have_submit_button do |value| match do |actual| actual.should have_selector("input[type=submit][value='#{value}']") end end </code></pre> <p>Here's the RSpec3 version (courtesy @zwippie):</p> <pre><code>RSpec::Matchers.define :have_submit_button do |value| match do |actual| expect(actual).to have_selector("input[type=submit][value='#{value}']") end end </code></pre> <p>I keep it in <code>spec/support/matchers/request_matchers.rb</code> with my other custom matchers. RSpec picks it up automatically. Since this is an RSpec matcher (rather than a Capybara finder), it will work in both feature specs (Capybara) and view specs (RSpec without Capybara).</p> <p>Feature spec usage:</p> <pre><code>page.should have_submit_button("Save Me") </code></pre> <p>View spec usage (after calling <code>render</code>):</p> <pre><code>rendered.should have_submit_button("Save Me") </code></pre> <p>Note that if you're in a Capybara request spec, and you would like to interact with a submit button, that's a lot easier:</p> <pre><code>click_button "Save Me" </code></pre> <p>There's no guarantee that it's actually a submit button, but your feature specs should just be testing the behavior and not worrying about that level of detail.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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