This repository has been archived by the owner on Oct 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cucumber/capybara features for user authentication
- Loading branch information
Barrett Griffith
committed
Sep 12, 2012
1 parent
d480030
commit 37fe099
Showing
11 changed files
with
325 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<% | ||
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" | ||
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" | ||
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" | ||
%> | ||
default: <%= std_opts %> features | ||
wip: --tags @wip:3 --wip features | ||
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Feature: New user Feature | ||
In order to connect with DPLA | ||
As a user who wants to connect to DPLA | ||
|
||
Scenario: user does NOT have an account | ||
Given a visitor to the home page | ||
When they choose the log in | ||
Then the reponse should be "200" | ||
When they try and sign in with user "mrtestuser@somedomain.com" and with password "testpass" | ||
Then they should not see "Log Out" | ||
Scenario: user signes up | ||
Given a visitor to the home page | ||
When they choose to sign up | ||
Then the response should be "200" | ||
When they sign up with user "mrtestuser@somedomain.com" and with password "testpass" and password confirmation "testpass" | ||
Then they should see "Log Out" | ||
|
||
Scenario: user does have an accoiunt | ||
Given a visitor to the home page | ||
When they choose the log in | ||
Then the reponse should be "200" | ||
When they try and sign in with user "mrtestuser@somedomain.com" and with password "testpass" | ||
Then they should see "Log Out" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
When /^I go to the homepage$/ do | ||
visit("/") | ||
end | ||
|
||
Then /^I should see "(.*?)"$/ do |arg1| | ||
page.should have_content("DP.LA") | ||
end | ||
|
||
Then /^I should not see "(.*?)"$/ do |arg1| | ||
page.should_not have_content(arg1) | ||
end | ||
|
||
|
||
When /^I follow "(.*?)"$/ do |arg1| | ||
click_link arg1 | ||
page.should have_content "Email" | ||
end | ||
|
||
|
||
|
||
When /^I fill in the following:$/ do |table| | ||
fill_in "Email", :with => "mrtestuser@somedomain.com" | ||
fill_in "Password", :with => "testpass" | ||
end | ||
|
||
When /^I press "(.*?)"$/ do |arg1| | ||
|
||
click_on "Sign in" | ||
page.should_not have_content "Sign Out" | ||
|
||
end | ||
|
||
|
||
Given /^the following user exists:$/ do |table| | ||
table.hashes.each do |attributes| | ||
lambda{ User.create!(attributes)}.should change(User, :count).by(1) | ||
end | ||
end | ||
|
||
When /^I log in with the following:$/ do |table| | ||
visit "/" | ||
click_link "Log In" | ||
table.hashes.each do |hash| | ||
fill_in "Email", :with => hash["Email"] | ||
fill_in "Password", :with => hash["Password"] | ||
end | ||
click_button "Sign in" | ||
end | ||
|
||
Then /^I should see "(.*?)" link$/ do |arg1| | ||
page.should have_content arg1 | ||
end | ||
|
||
Then /^I should not see "(.*?)" link$/ do |arg1| | ||
page.should_not have_content arg1 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
When /I sign in/ do | ||
visit('/') | ||
page.should have_content("DP.LA") | ||
click_link 'Sign Up' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. | ||
# It is recommended to regenerate this file in the future when you upgrade to a | ||
# newer version of cucumber-rails. Consider adding your own code to a new file | ||
# instead of editing this one. Cucumber will automatically load all features/**/*.rb | ||
# files. | ||
|
||
require 'cucumber/rails' | ||
|
||
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In | ||
# order to ease the transition to Capybara we set the default here. If you'd | ||
# prefer to use XPath just remove this line and adjust any selectors in your | ||
# steps to use the XPath syntax. | ||
Capybara.default_selector = :css | ||
|
||
# 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 | ||
# be rendered instead. | ||
# | ||
# Sometimes we want to override this default behaviour and allow Rails to rescue | ||
# exceptions and display an error page (just like when the app is running in production). | ||
# Typical scenarios where you want to do this is when you test your error pages. | ||
# There are two ways to allow Rails to rescue exceptions: | ||
# | ||
# 1) Tag your scenario (or feature) with @allow-rescue | ||
# | ||
# 2) Set the value below to true. Beware that doing this globally is not | ||
# recommended as it will mask a lot of errors for you! | ||
# | ||
ActionController::Base.allow_rescue = false | ||
|
||
# Remove/comment out the lines below if your app doesn't have a database. | ||
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead. | ||
begin | ||
DatabaseCleaner.strategy = :transaction | ||
rescue NameError | ||
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." | ||
end | ||
|
||
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios. | ||
# See the DatabaseCleaner documentation for details. Example: | ||
# | ||
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do | ||
# # { :except => [:widgets] } may not do what you expect here | ||
# # as tCucumber::Rails::Database.javascript_strategy overrides | ||
# # this setting. | ||
# DatabaseCleaner.strategy = :truncation | ||
# end | ||
# | ||
# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do | ||
# DatabaseCleaner.strategy = :transaction | ||
# end | ||
# | ||
|
||
# Possible values are :truncation and :transaction | ||
# The :transaction strategy is faster, but might give you threading problems. | ||
# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature | ||
Cucumber::Rails::Database.javascript_strategy = :truncation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Feature: User Authentication | ||
|
||
Scenario: un-successful DPLA authentication | ||
When I go to the homepage | ||
Then I should see "Log In" | ||
But I should not see "Sign Out" | ||
When I follow "Log In" | ||
And I fill in the following: | ||
| Email | mrtestuser@somedomain.com | | ||
| Password | test | | ||
And I press "Sign in" | ||
Then I should see "Sign In" | ||
But I should not see "Sign Out" | ||
|
||
Scenario: successful DPLA sign up | ||
When I go to the homepage | ||
Then I should see "Sign Up" | ||
But I should not see "Sign Out" | ||
When I follow "Sign Up" | ||
And I fill in the following: | ||
| Email | mrtestuser@somedomain.com | | ||
| Password | testpass | | ||
| Password confirmation | testpass | | ||
And I press "Sign up" | ||
Then I should see "Sign Out" | ||
But I should not see "Sign In" | ||
|
||
Scenario: successful DPLA authentication | ||
Given the following user exists: | ||
| email | password | password_confirmation | | ||
| mrtestuser@somedomain.com | testpass | testpass | | ||
When I go to the homepage | ||
Then I should see "Log In" | ||
But I should not see "Sign Out" | ||
When I follow "Log In" | ||
And I log in with the following: | ||
| Email | Password | | ||
| mrtestuser@somedomain.com | testpass | | ||
Then I should see "Sign Out" link | ||
But I should not see "Sign In" link |
Oops, something went wrong.