From d206f2bd8c588eae35ba27fb08b97763bb867809 Mon Sep 17 00:00:00 2001 From: Rafael Reggiani Manzo Date: Thu, 27 Jun 2013 21:24:12 -0300 Subject: [PATCH] Homepage acceptance tests --- Gemfile.lock | 2 +- features/homepage.feature | 16 ++++++++++++++++ features/step_definitions/homepage_steps.rb | 15 +++++++++++++++ features/support/env.rb | 6 ++++-- spec/factories/users.rb | 1 + 5 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 features/homepage.feature create mode 100644 features/step_definitions/homepage_steps.rb diff --git a/Gemfile.lock b/Gemfile.lock index dbc1382..c624044 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,7 +26,7 @@ GEM thread_safe (~> 0.1) tzinfo (~> 0.3.37) arel (4.0.0) - atomic (1.1.9) + atomic (1.1.10) bcrypt-ruby (3.0.1) builder (3.1.4) capybara (2.1.0) diff --git a/features/homepage.feature b/features/homepage.feature new file mode 100644 index 0000000..470515f --- /dev/null +++ b/features/homepage.feature @@ -0,0 +1,16 @@ +Feature: Homepage + In Order to have a good interaction with the website + As a regular user + I want to have in one page useful links to manage my account and session + + Scenario: Before signing in + Given I am at the homepage + Then I should see Login + And I should see Sign Up + + Scenario: Signed in + Given I am a regular user + And I am signed in + And I am at the homepage + Then I should see Edit + And I should see Logout \ No newline at end of file diff --git a/features/step_definitions/homepage_steps.rb b/features/step_definitions/homepage_steps.rb new file mode 100644 index 0000000..c821f6d --- /dev/null +++ b/features/step_definitions/homepage_steps.rb @@ -0,0 +1,15 @@ +Given(/^I am at the homepage$/) do + visit root_path +end + +Given(/^I am signed in$/) do + login_as(@user, :scope => :user) +end + +Given(/^I am a regular user$/) do + @user = FactoryGirl.create(:user) +end + +Then(/^I should see (.+)$/) do |text| + page.should have_content(text) +end \ No newline at end of file diff --git a/features/support/env.rb b/features/support/env.rb index 9f3b86d..1231042 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -12,8 +12,8 @@ require 'cucumber/rails' # Capybara.default_selector = :xpath # By default, any exception happening in your Rails application will bubble up -# to Cucumber so that your scenario will fail. This is a different from how -# your application behaves in the production environment, where an error page will +# to Cucumber so that your scenario will fail. This is a different from how +# your application behaves in the production environment, where an error page will # be rendered instead. # # Sometimes we want to override this default behaviour and allow Rails to rescue @@ -56,3 +56,5 @@ end # See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature Cucumber::Rails::Database.javascript_strategy = :truncation +# Warden test helpers so the user authentication can be as fast as possible +include Warden::Test::Helpers \ No newline at end of file diff --git a/spec/factories/users.rb b/spec/factories/users.rb index a8976a2..a4d9fc8 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -4,5 +4,6 @@ FactoryGirl.define do factory :user do name "Diego Martinez" email "diego@email.com" + password "password" end end -- libgit2 0.21.2