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

Posting a Message

To implement our second step, we’re going to cheat again and simulate the posting of a message by calling the models directly. This allows us to focus on building the messages page without getting too distracted. Let’s implement the second step definition:

 Given(​/^the User has posted the message "([^"]*)"$/​) ​do​ |message_text|
  expect(User.count).to eq 1
  FactoryGirl.create(​:message​, ​:content​ => message_text, ​:user​ => User.first)
 end
Joe asks:
Joe asks:
When Do I Use the UI and When Do I Use Models Directly to Create Records?

A Given means that something has happened in the ...

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