Hi Andrei, >>> This is the step: >>> >>> Given /I am logged in as a user/ do >>> @current_user = Factory.define :user do |u| >>> u.name 'the user' >>> u.email '[EMAIL PROTECTED]' >>> u.login 'the_login' >>> u.password 'password' >>> u.password_confirmation 'password' >>> end >>> visits "/login" >>> fills_in("login", :with => "the_login") >>> fills_in("password", :with => "password") >>> clicks_button("Log in") >>> end
you can simplify the code to activate the user. This is my step definition for login: When /^i login$/ do user = Factory(:user) user.register! user.activate! fill_in("username", :with => user.login) fill_in("password", :with => user.password) click_button("Login") end This is my factory code in test/factories.rb Factory.define :user do |u| u.login 'user' u.password 'password' u.password_confirmation 'password' u.email '[EMAIL PROTECTED]' end I think i saw a fork of factory_girl somewhere that supported before and after hooks so you could actually call the register and activate methods after save from within the factory definition code. This way your steps and other tests would be much cleaner. I will look further into it. Cheers, Alberto. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users