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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.