27.02.2013 Views

Rails%203%20In%20Action

Rails%203%20In%20Action

Rails%203%20In%20Action

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

126 CHAPTER 6 Authentication and basic authorization<br />

When you run bin/cucumber features/signing_up.feature, the entire feature is<br />

passing:<br />

1 scenario (1 passed)<br />

5 steps (5 passed)<br />

In addition to signing-up facilities, Devise handles all the signing-in facilities too. All<br />

you need to add is the :confirmable symbol to the devise call in the model, the confirmation<br />

fields to the users table, and the message “Signed in as [user]” in your<br />

application—three easy steps.<br />

Does everything else pass? Run rake cucumber:ok spec, and you should see the<br />

following output:<br />

15 scenarios (15 passed)<br />

120 steps (120 passed)<br />

# and<br />

6 examples, 0 failures, 5 pending<br />

Great! Push that!<br />

git add .<br />

git commit -m "Added feature for ensuring that a user is signed in<br />

via a confirmation email by using email spec"<br />

git push<br />

Now that users can sign up and confirm their email addresses, what should happen<br />

when they return to the site? They should be able to sign in! Let’s make sure this can<br />

happen.<br />

6.4 Form sign-in<br />

The previous story covered the automatic sign-in that happens when users follow the<br />

confirmation link from the email they receive when they sign up. Now you must write<br />

a story for users who have confirmed their account and are returning and need to sign<br />

in again.<br />

Place the scenario in the following listing directly underneath the previous scenario<br />

in features/signing_in.feature.<br />

Listing 6.6 features/signing_in.feature<br />

Scenario: Signing in via form<br />

Given there are the following users:<br />

| email | password |<br />

| user@ticketee.com | password |<br />

And I am on the homepage<br />

When I follow "Sign in"<br />

And I fill in "Email" with "user@ticketee.com"<br />

And I fill in "Password" with "password"<br />

And I press "Sign in"<br />

Then I should see "Signed in successfully."<br />

When you run bin/cucumber features/signing_in.feature, it complains about the<br />

missing Sign In link:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!