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 ...

Get The Cucumber Book, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.