Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Given 'I am a registered user' do
- #because this is a given, we can talk directly to the model class if it is easier.
- @user = User.new(
- :login => 'user-#{rand(10000)}', #keep login unique
- :name => "Joe User", #different data should look different. Easier to debug
- :email => 'edgemerb@gmail.com',
- :password => "{rand(10000)}")
- @user.password_confirmation = @user.password
- @user.activated_at = Time.now #Is this all a user needs to be active?
- @user.save!
- end
- Given 'I am an admin' do
- Given 'I am a registered user'
- @user..set_role("admin")
- @user.save!
- end
- When /^I login as "(.*)" with "(.*)"$/ do |name, pass| #I wonder how useful this is
- visit "/"
- click_link "Sign in"
- fill_in "Login", :with => "#{name}"
- fill_in "Password", :with => "#{pass}"
- #session.user = User.first(:login => "#{name}")
- @response = click_button("Log in")
- end
- Given /^I login$/ do
- unless @user do #if there is not a user make one to login with
- Given 'I an a registered user'
- end
- visit "/"
- click_link "Sign in"
- fill_in "Login", :with => @user.login
- fill_in "Password", :with => @user.password
- click_button("Log in")
- end
Add Comment
Please, Sign In to add comment