Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Mateus Gomes's Profile

GitHub User: mateusg

Comments by Mateus Gomes

Avatar

Hi Ryan. I was wondering how you test validations. Do you always do it through integration tests (like in the example below) or do you use something else?

ruby
visit new_employee_path
click_button "Save"

page.should have_content "Name can't be blank"
page.should have_content "Age can't be blank"

fill_in "Name", :with => "John Doe"
fill_in "Age", :with => "something"
click_button "Save"

page.should have_content "Age must be a number"
# ...

If you do use integration tests, what's your advice to make the code cleaner/less repetitive?

Thanks for the great screencast!

Avatar

The link to Advanced Rails Recipes is broken.