Created
January 31, 2011 16:21
-
-
Save JohnPlummer/804289 to your computer and use it in GitHub Desktop.
Authentication with devise - Features
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
Feature: Authentication | |
So that users can be associated with an account | |
As the site owner | |
I want users to login |
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
Feature: Authentication | |
So that users can be associated with an account | |
As the site owner | |
I want users to login | |
Scenario: User not signed in | |
Given I am not signed in | |
When I go to the home page | |
Then I should be redirected to the sign in page |
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
module NavigationHelpers | |
# Maps a name to a path. Used by the | |
# | |
# When /^I go to (.+)$/ do |page_name| | |
# | |
# step definition in web_steps.rb | |
# | |
def path_to(page_name) | |
case page_name | |
when /the home\s?page/ | |
'/' | |
# Add more mappings here. | |
# Here is an example that pulls values out of the Regexp: | |
# | |
# when /^(.*)'s profile page$/i | |
# user_profile_path(User.find_by_login($1)) | |
else | |
begin | |
page_name =~ /the (.*) page/ | |
path_components = $1.split(/\s+/) | |
self.send(path_components.push('path').join('_').to_sym) | |
rescue Object => e | |
raise "Can't find mapping from \"#{page_name}\" to a path.\n" + | |
"Now, go and add a mapping in #{__FILE__}" | |
end | |
end | |
end | |
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
module NavigationHelpers | |
... | |
def path_to(page_name) | |
case page_name | |
when /the home\s?page/ | |
'/' | |
when /the sign in page/ | |
new_user_session_path | |
... | |
end | |
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
Given /^I am not signed in$/ do | |
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
... | |
Then /^(?:|I )should be on (.+)$/ do |page_name| | |
current_path = URI.parse(current_url).path | |
if current_path.respond_to? :should | |
current_path.should == path_to(page_name) | |
else | |
assert_equal path_to(page_name), current_path | |
end | |
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
... | |
Then /^(?:|I )should be redirected to (.+)$/ do |page_name| | |
Then "I should be on #{page_name}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment