Commit d206f2bd8c588eae35ba27fb08b97763bb867809

Authored by Rafael Manzo
1 parent 378f2fe3

Homepage acceptance tests

Gemfile.lock
... ... @@ -26,7 +26,7 @@ GEM
26 26 thread_safe (~> 0.1)
27 27 tzinfo (~> 0.3.37)
28 28 arel (4.0.0)
29   - atomic (1.1.9)
  29 + atomic (1.1.10)
30 30 bcrypt-ruby (3.0.1)
31 31 builder (3.1.4)
32 32 capybara (2.1.0)
... ...
features/homepage.feature 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +Feature: Homepage
  2 + In Order to have a good interaction with the website
  3 + As a regular user
  4 + I want to have in one page useful links to manage my account and session
  5 +
  6 + Scenario: Before signing in
  7 + Given I am at the homepage
  8 + Then I should see Login
  9 + And I should see Sign Up
  10 +
  11 + Scenario: Signed in
  12 + Given I am a regular user
  13 + And I am signed in
  14 + And I am at the homepage
  15 + Then I should see Edit
  16 + And I should see Logout
0 17 \ No newline at end of file
... ...
features/step_definitions/homepage_steps.rb 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +Given(/^I am at the homepage$/) do
  2 + visit root_path
  3 +end
  4 +
  5 +Given(/^I am signed in$/) do
  6 + login_as(@user, :scope => :user)
  7 +end
  8 +
  9 +Given(/^I am a regular user$/) do
  10 + @user = FactoryGirl.create(:user)
  11 +end
  12 +
  13 +Then(/^I should see (.+)$/) do |text|
  14 + page.should have_content(text)
  15 +end
0 16 \ No newline at end of file
... ...
features/support/env.rb
... ... @@ -12,8 +12,8 @@ require 'cucumber/rails'
12 12 # Capybara.default_selector = :xpath
13 13  
14 14 # By default, any exception happening in your Rails application will bubble up
15   -# to Cucumber so that your scenario will fail. This is a different from how
16   -# your application behaves in the production environment, where an error page will
  15 +# to Cucumber so that your scenario will fail. This is a different from how
  16 +# your application behaves in the production environment, where an error page will
17 17 # be rendered instead.
18 18 #
19 19 # Sometimes we want to override this default behaviour and allow Rails to rescue
... ... @@ -56,3 +56,5 @@ end
56 56 # See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature
57 57 Cucumber::Rails::Database.javascript_strategy = :truncation
58 58  
  59 +# Warden test helpers so the user authentication can be as fast as possible
  60 +include Warden::Test::Helpers
59 61 \ No newline at end of file
... ...
spec/factories/users.rb
... ... @@ -4,5 +4,6 @@ FactoryGirl.define do
4 4 factory :user do
5 5 name "Diego Martinez"
6 6 email "diego@email.com"
  7 + password "password"
7 8 end
8 9 end
... ...