views:

44

answers:

1

Hello everyone !

I am currently trying to use the Pickle gem for my cucumber test in ruby and rails. I use blueprints. If I have a User class, with an id as primary key, and a "name" and a "best_friend_id" as attributes. How can I access to the id of the first User "Toto" to fill the best_friend_id field of "Titi" in my Pickle steps?

For example:

Given a user exists with name: "Toto"
Given a user exists with name: "Titi", best_friend_id: ??"Toto".id??

Probably a simple question, but I don't see this case in the little tutos I saw.

Please help the french newbie I am =)

A: 

I use Cucumber, but not Pickle, so this isn't tested. However, from reading the docs it looks like you can access associations like this:

Given a user exists with name: "Titi", best_friend: user "Toto"

There are assertions you can make on these as well. Scroll down to "Then steps".

http://rdoc.info/projects/ianwhite/pickle

jdl
yes thanks but I would need to use the id of the user "Toto" not the user object itself
Lucas L.
Did you try it? Notice that the association field is named "best_friend" not "best_friend_id". Pickle should be taking care of the IDs behind the scenes.
jdl