[rspec-users] Restful Authentication and Cucumber
matt at mattwynne.net
Fri Nov 28 06:14:44 EST 2008
On 27 Nov 2008, at 23:38, Michael Guterl wrote:
> On Thu, Nov 27, 2008 at 12:58 AM, Andrei Erdoss <erdoss at gmail.com>
>> I am using Restful Authentication and I would like to login in
>> Cucumber. I
>> am having trouble keeping the user logged in. I tried finding a
>> solution for
>> this everywhere. Only source is this article:
>> This is how my feature looks like:
>> Scenario: Register new place
>> Given I am logged in as a user
>> And I am on the new place page with parent place "Georgia"
>> When I fill in "Name" with "Atlanta"
>> And I press "Create"
>> And I should see "Atlanta"
>> 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 'erdoss at gmail.com'
>> u.login 'the_login'
>> u.password 'password'
>> u.password_confirmation 'password'
>> visits "/login"
>> fills_in("login", :with => "the_login")
>> fills_in("password", :with => "password")
>> clicks_button("Log in")
> I don't think Factory.define returns the instance that you defined and
> defining the factory certainly does not store the instance to the
> I'd recommend putting your factories in a separate file and require
> them at the beginning of your step file.
That's the whole point of the factory_girl - re-usable test data!
Once you've got that set up, a whole new world opens up.
For example, at Songkick, we have a step like this:
Given /there is (?:one|an?) ([^ ]+)$/ do |entity_type|
> You could then do @current_user = Factory(:user), which will actually
> store the user to the database.
> Michael Guterl
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users