Rails functional test assert_select form input value?

Viewed 6701

I'm writing a simple test to check that a form is loading the correct values.

I've looked through the docs and can't seem to find an example that shows how to verify the value of a form input.

I have a form that renders the first_name of a user.

I just want to use assert_select on the text input and verify that the first_name field matches what's in the database exactly (e.g users(:one).first_name)

How does one do this in Rails?

2 Answers

Checkbox: If you want to assert_select a checked checkbox (in this case 1 checked checkbox), try this:

assert_select 'input[type=checkbox][checked]', 1

Not 100% related to the question, but more for documentation purpose for others.

Related