Forum: Ruby on Rails How to assert the value of an input element with assert_select (Rails 4)

A00673345921ae8c2e5570d1bd48b2e2?d=identicon&s=25 J. mp (lerias)
on 2013-07-19 13:17
(Received via mailing list)
Given this HTML in the view:

<form id="new_merchant_user" method="post">
  <fieldset>
    <div id='legend'>
       <legend>Recover Pasword</legend>
     </div>
     <input id="merchant_user_email" name="merchant_user[email]"
type="text" value="" />
     <input class="btn btn-success" name="commit" type="submit"
value="Send Reset Instructions" />

   </fieldset></form>

How do I select the value of the button with assert_select? I try

assert_select 'form input[type=submit]', "Send Reset Instructions"

but its failing with

<Send Reset Instructions> expected but was
<>..
Expected 0 to be >= 1.

Basically, selecting nothing.

What am I doing wrong here?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2013-07-19 13:19
(Received via mailing list)
On Thursday, July 18, 2013 11:53:01 AM UTC+1, Joo Pereira wrote:
>
> Given this HTML in the view:
>
> How do I select the value of the button with assert_select? I try
>
> assert_select 'form input[type=submit]', "Send Reset Instructions"
>
>
> This checks whether the input element contains that text, which doesn't
look at attributes.

assert_select "form input[type=submit][value='Send Reset Instructions']"


should do the trick

Fred
A00673345921ae8c2e5570d1bd48b2e2?d=identicon&s=25 J. mp (lerias)
on 2013-07-19 13:44
(Received via mailing list)
Will try that. Thanks
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.