advertisement

Print

Cookin' with Ruby on Rails - Integration Tests
Pages: 1, 2, 3, 4, 5, 6, 7

Boss: It'll do for now. I may want to add more later, but for now, let's move on to the other pages.

CB: Excellent! But first, let's run the new tests to make sure they're working.

done with the home page
Figure 23

Alllll righty, then! Let's get on with it! I think I'll go ahead and test the "Create a new recipe" link now. That way, we'll be done with Recipes altogether when we test the "Show all categories" link. Let's take a look at where we are.

cookbook2_integration_test contents
Figure 24

IMPORTANT NOTE TO READER: The two assert_raise lines in the image above have been formatted on two lines to accomodate the width restrictions for images for O'Reilly online publications. Please make sure that your code has the assert_raise statement all on one line. As in...

assert_raise(Test::Unit::AssertionFailedError) {assert_select "a", {:text=>"pizza"}}

So now let's add the methods to test our "Create a recipe" code. We've already tested that the correct link is on the page in our check_the_home_page_footer method. So here, we could pick up by browsing to that page, or we could start by browsing to the home page to use that link. What do you think, Boss?

Pages: 1, 2, 3, 4, 5, 6, 7

Next Pagearrow