mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-24 03:00:12 +01:00
update cucumber and refactor some of the stories
inspired by the railscasts about cucumber. Also fix a problem with ZenTest on case sensitive platforms
This commit is contained in:
parent
bdddac5020
commit
2073f84cd8
11 changed files with 90 additions and 128 deletions
|
|
@ -1,69 +1,14 @@
|
|||
Given /^I am logged in$/ do
|
||||
@current_user = User.create!(:login => "testuser", :password => "secret", :password_confirmation => "secret")
|
||||
@current_user.create_preference
|
||||
Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password|
|
||||
visit login_path
|
||||
fill_in "login", :with => "testuser"
|
||||
fill_in "password", :with => "secret"
|
||||
fill_in "login", :with => username
|
||||
fill_in "password", :with => password
|
||||
click_button "Sign in"
|
||||
response.body.should =~ /Login successful/m
|
||||
@current_user = User.find_by_login(username)
|
||||
end
|
||||
|
||||
Given /^public signups are turned (.*)$/ do |state|
|
||||
case state
|
||||
when 'on'
|
||||
SITE_CONFIG['open_signups'] = true
|
||||
when 'off'
|
||||
SITE_CONFIG['open_signups'] = false
|
||||
else
|
||||
raise "public signups should be either 'on' or 'off'"
|
||||
end
|
||||
end
|
||||
|
||||
When "I successfully submit the signup form" do
|
||||
fill_in 'Desired login', :with => 'reinier'
|
||||
fill_in 'Choose password', :with => 'abracadabra'
|
||||
fill_in 'Confirm password', :with => 'abracadabra'
|
||||
When /^I submit the login form as user "([^\"]*)" with password "([^\"]*)"$/ do |username, password|
|
||||
fill_in 'Login', :with => username
|
||||
fill_in 'Password', :with => password
|
||||
click_button
|
||||
end
|
||||
|
||||
When "I submit signup form with dissimmilar password and confirmation" do
|
||||
fill_in 'Desired login', :with => 'reinier'
|
||||
fill_in 'Choose password', :with => 'abracadabra'
|
||||
fill_in 'Confirm password', :with => 'somethingelse'
|
||||
click_button
|
||||
end
|
||||
|
||||
Then "I should be an admin" do
|
||||
# just check on the presence of the menu item for managing users
|
||||
Then "I should see \"Manage users\""
|
||||
end
|
||||
|
||||
When "I submit the login form as an admin user with an incorrect password" do
|
||||
Given "an admin user exists"
|
||||
fill_in 'Login', :with => 'admin'
|
||||
fill_in 'Password', :with => 'incorrectpass'
|
||||
click_button
|
||||
end
|
||||
|
||||
When "I successfully submit the login form as an admin user" do
|
||||
Given "an admin user exists"
|
||||
fill_in 'Login', :with => 'admin'
|
||||
fill_in 'Password', :with => 'abracadabra'
|
||||
click_button
|
||||
end
|
||||
|
||||
When "Reinier visits the site" do
|
||||
visits '/'
|
||||
end
|
||||
|
||||
Then "Reinier should see the tasks listing page" do
|
||||
response.should have_tag('title', /list tasks/i)
|
||||
end
|
||||
|
||||
Then "Reinier should see the login page again" do
|
||||
response.should have_tag('title', /login/i)
|
||||
end
|
||||
|
||||
Then "Reinier should see the message Login unsuccessful" do
|
||||
should_see 'Login unsuccessful'
|
||||
end
|
||||
17
features/step_definitions/signup_steps.rb
Normal file
17
features/step_definitions/signup_steps.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
Given /^public signups are turned (.*)$/ do |state|
|
||||
case state
|
||||
when 'on'
|
||||
SITE_CONFIG['open_signups'] = true
|
||||
when 'off'
|
||||
SITE_CONFIG['open_signups'] = false
|
||||
else
|
||||
raise "public signups should be either 'on' or 'off'"
|
||||
end
|
||||
end
|
||||
|
||||
When /^I submit the signup form with username "([^\"]*)", password "([^\"]*)" and confirm with "([^\"]*)"$/ do |username, password, confirm|
|
||||
fill_in 'Desired login', :with => username
|
||||
fill_in 'Choose password', :with => password
|
||||
fill_in 'Confirm password', :with => confirm
|
||||
click_button
|
||||
end
|
||||
|
|
@ -1,37 +1,15 @@
|
|||
Given /^the following user records?$/ do |table|
|
||||
table.hashes.each do |hash|
|
||||
user = Factory(:user, hash)
|
||||
user.create_preference
|
||||
end
|
||||
end
|
||||
|
||||
Given "no users exists" do
|
||||
User.delete_all
|
||||
end
|
||||
|
||||
Given "an admin user exists" do
|
||||
if @admin_user
|
||||
@admin_user.destroy
|
||||
end
|
||||
@admin_user = User.create!(:login => 'admin', :password => 'abracadabra', :password_confirmation => 'abracadabra')
|
||||
@admin_user.is_admin = true # is_admin is protected in user model
|
||||
@admin_user.create_preference
|
||||
@admin_user.preference.save
|
||||
@admin_user.save
|
||||
end
|
||||
|
||||
Given "an admin user Reinier with the password abracadabra" do
|
||||
@reinier = User.create!(:login => 'reinier', :password => 'abracadabra', :password_confirmation => 'abracadabra', :is_admin => true)
|
||||
@reinier.create_preference
|
||||
end
|
||||
|
||||
Given "an admin user Reinier" do
|
||||
Given "an admin user Reinier with the password abracadabra"
|
||||
end
|
||||
|
||||
Given "a logged in user Luis" do
|
||||
@luis = User.create!(:login => 'luis', :password => 'sesame', :password_confirmation => 'sesame', :is_admin => false)
|
||||
@luis.create_preference
|
||||
logged_in_as @luis
|
||||
end
|
||||
|
||||
Given "Reinier is not logged in" do
|
||||
#nothing to do
|
||||
end
|
||||
|
||||
Given "a visitor named Reinier" do
|
||||
#nothing to do
|
||||
end
|
||||
Then "I should be an admin" do
|
||||
# just check on the presence of the menu item for managing users
|
||||
Then "I should see \"Manage users\""
|
||||
end
|
||||
|
|
@ -98,6 +98,14 @@ Then /^I should not see "([^\"]*)"$/ do |text|
|
|||
response.should_not contain(text)
|
||||
end
|
||||
|
||||
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
|
||||
field_labeled(field).value.should =~ /#{value}/
|
||||
end
|
||||
|
||||
Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
|
||||
field_labeled(field).value.should_not =~ /#{value}/
|
||||
end
|
||||
|
||||
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
||||
field_labeled(label).should be_checked
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue