Skip to content
Browse files

Wrote some stories

  • Loading branch information...
1 parent 1f053f3 commit 6eda38bd39442b813c0fbde24ed13c4d9523e945 @fd fd committed Feb 8, 2009
View
48 features/manage_projects.feature
@@ -0,0 +1,48 @@
+Feature: Users can manage projects
+
+ As a user
+ I want to manage projects
+ So that I can group my error reports
+
+ Scenario: Create a project with a valid name
+ Given a user is logged in as "john-doe"
+ When I go to the new project page
+ And I fill in "Name" with "My Project"
+ And I press "Create"
+ Then I should see "My Project"
+
+ Scenario: Create a project with an invalid name
+ Given a user is logged in as "john-doe"
+ When I go to the new project page
+ And I fill in "Name" with ""
+ And I press "Create"
+ Then I should see "Name can't be blank"
+
+ Scenario: Edit a Project with a valid name
+ Given a user is logged in as "john-doe"
+ Given a project "My Project" owned by "john-doe"
+ When I go to the homepage
+ And I follow "My Project"
+ And I follow "Edit project"
+ And I fill in "Name" with "My Other Project"
+ And I press "Save"
+ Then I should see "My Other Project"
+
+ Scenario: Edit a Project with an invalid name
+ Given a user is logged in as "john-doe"
+ Given a project "My Project" owned by "john-doe"
+ When I go to the homepage
+ And I follow "My Project"
+ And I follow "Edit project"
+ And I fill in "Name" with ""
+ And I press "Save"
+ Then I should see "Name can't be blank"
+
+ Scenario: Destroy a Project
+ Given a user is logged in as "john-doe"
+ Given a project "My Project" owned by "john-doe"
+ When I go to the homepage
+ And I follow "My Project"
+ And I follow "Edit project"
+ And I follow "Delete this project"
+ Then I should not see "My Project"
View
4 features/sign_on.feature
@@ -4,15 +4,15 @@ Guests should be able to
Login to there accounts
Scenario: Login with valid credentials
- Given a registered user with login "john-doe" and password "my password"
+ Given a user with login "john-doe" and password "my password"
When I go to the login page
And I fill in "Login" with "john-doe"
And I fill in "Password" with "my password"
And I press "Login"
Then I should see "New project"
Scenario: Login with valid credentials
- Given a registered user with login "john-doe" and password "my password"
+ Given a user with login "john-doe" and password "my password"
When I go to the login page
And I fill in "Login" with "john-doe"
And I fill in "Password" with ""
View
6 features/step_definitions/project_steps.rb
@@ -0,0 +1,6 @@
+# Given a project "My Project" owned by "john-doe"
+
+Given /^a project "(.+)" owned by "(.+)"$/ do |project_name, owner_login|
+ user = User.find_by_login(owner_login)
+ user.projects.create!(:name => project_name)
+end
View
23 features/step_definitions/user_steps.rb
@@ -1,4 +1,25 @@
-Given /^a registered user with login "(.+)" and password "(.+)"$/ do |login, password|
+Given /^a user with login "(.+)" and password "(.+)"$/ do |login, password|
@user = Factory(:user, :login => login, :password => password, :password_confirmation => password)
+end
+
+Given /^a user with login "(.+)"$/ do |login|
+ @user = Factory(:user, :login => login,
+ :password => "password", :password_confirmation => "password")
+end
+
+Given /^a user is logged in as "(.*)"$/ do |login|
+ @current_user = User.create!(
+ :name => login,
+ :login => login,
+ :password => 'generic',
+ :password_confirmation => 'generic',
+ :email => "#{login}@example.com"
+ )
+
+ visit "/user_session/new"
+ fill_in("Login", :with => login)
+ fill_in("Password", :with => 'generic')
+ click_button("Login")
+ assert_match(/New project/m, response.body)
end
View
2 features/step_definitions/webrat_steps.rb
@@ -91,7 +91,7 @@
end
Then /^I should not see "(.*)"$/ do |text|
- assert_not_match(/#{text}/m, response.body)
+ assert_no_match(/#{text}/m, response.body)
end
Then /^the "(.*)" checkbox should be checked$/ do |label|
View
2 features/support/paths.rb
@@ -7,6 +7,8 @@ def path_to(page_name)
new_account_path
when /the login page/i
new_user_session_path
+ when /the new project page/i
+ new_project_path
else
raise "Can't find mapping from \"#{page_name}\" to a path."

0 comments on commit 6eda38b

Please sign in to comment.
Something went wrong with that request. Please try again.