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:
Reinier Balt 2009-05-22 23:14:40 +02:00
parent bdddac5020
commit 2073f84cd8
11 changed files with 90 additions and 128 deletions

View file

@ -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