2010-08-16 11 views

risposta

9

ecco come lo faccio.

Given /^I have one\s+user "([^\"]*)" with email "([^\"]*)" and password "([^\"]*)"$/ do |username,email, password| 
    @user = User.new(:email => email, 
        :username=>username, 
        :password => password, 
        :password_confirmation => password) 
    @user.save! 
end 

Given /^I am an authenticated user$/ do 
    name = 'exmample' 
    email = '[email protected]' 
    password = 'secret!' 

    Given %{I have one user "#{name}" with email "#{email}" and password "#{password}"} 
    And %{I go to the user login page} 
    And %{I fill in "user_username" with "#{name}"} 
    And %{I fill in "user_password" with "#{password}"} 
    And %{I press "Sign in"} 
end 

La ragione per cui lo faccio in questo modo, è che ho eseguito attraverso l'intero stack e impostare l'ambiente il modo in cui un utente normale sarebbe ...

4

Hi Si può dividere questa fase in tre piccoli passi

1. visit login page 
2. fill_in login, username 
3. press login button 
Problemi correlati