DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Cucumber Testing Authentication
//top of steps file or in seperate factory file
require 'factory_girl'
Factory.define :user do |u|
u.login 'the_login'
u.email 'email@emailacc.com'
u.password 'password'
u.password_confirmation 'password'
# u.activated_at 'active'
end
// in steps file
Given /I am logged in as a user/ do
user = Factory(:user)
#when registration required
#user.register!
user.activate!
visits "/login"
fill_in("login", :with => user.login)
fill_in("password", :with => user.password)
click_button("Log in")
response.body.should =~ /Logged in successfully/
end





