O'Reilly logo

The Cucumber Book, 2nd Edition by Steve Tooke, Aslak Hellesoy, Matt Wynne

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing the View

Let’s make the last few changes to make our scenario pass. The next thing we need to do is to implement the last missing step. Add the following to features/step_definitions/view_steps.rb:

 Then(​/^I should see "([^"]*)"$/​) ​do​ |text|
  expect(page).to have_content(text)
 end

We’re using Capybara’s page object and have_content RSpec matcher here to verify that a snippet of text is on the page. We’ll explain more about that in the next chapter. This makes our step go from undefined to failing since the view doesn’t show what we want it to show. Remember—we just hard-coded a message in it.

We’ll work outside-in, starting with the app/views/users/show.html.erb view. Let’s ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required