Then a user: "blah" should exist

2 views
Skip to first unread message

theworldinunion

unread,
Mar 7, 2010, 4:28:40 AM3/7/10
to pickle
Hi,

I've been using pickle (0.2.2) with cucumber (0.6.2) and machinist
(1.0.6) for BDD, and it's amazing. Thank you for such a wonderful
library.

I have a question regarding how pickle is interpreting
Then a user: "blah" should exist
without user: "blah" being predefined.

Please refer to the scenario below
--
Scenario: Test
Given a user: "alpha" exists with login: "alpha" # line1,
passes, uses machinist to sham everything else
Then a user: "alpha" should exist #
line2, passes
Then a user: "blah" should exist #
line3, passes -> huh?
Then 1 users should exist #
line4, passes -> sounds reasonable
Then a user: "blah" should exist with login: "alpha"
#line5, passes -> huh?
Then a user: "blah" should exist with login: "blah"
#line6, fails
--

If I am interpreting this correctly, then :
(i) line 3 should not pass, since "blah" does not exist
(ii) line 5 should not pass, since "alpha" is not user: "blah"
(iii) line 6 fails. But if so, why did line 3 pass?

I am wondering if you can advice if this is a pickle bug, or just
whether the above is interpreted to be correct behaviour?

Thanks.

Ian White

unread,
Mar 7, 2010, 7:40:05 AM3/7/10
to pickle-...@googlegroups.com
Hi there,

This is expected behaviour.

When finding models you are essentially creating pickle refs to them
as well, and can name those refs just like when you create them.

The line 'then a user "blah" should exist' means something like 'then
a user should exist (and let's refer to it as "blah" from now on)'

An example of this being useful would be something like.

Given a user "creator" exists
When I login as the user "creator"
And I fill in the create user form with name: "fred" and press submit
Then a user "created" should exist with name "fred"
And the user "created" shoul be in the user "creator"'s managed_users


Or (example of subsidiary model being created)

Given a user "fred" exists
then a user address "feeds addy" should exist

The pickle ref is not tied to a particular field, it's just for
referring to models in cucumber scenarios. One model may have many
refs.

Does that clear things up?

Cheers,
Ian

Sent from my iPhone

On 7 Mar 2010, at 09:28, theworldinunion <theworl...@yahoo.co.jp>
wrote:

> --
> You received this message because you are subscribed to the Google
> Groups "pickle" group.
> To post to this group, send email to pickle-...@googlegroups.com.
> To unsubscribe from this group, send email to pickle-cucumb...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/pickle-cucumber?hl=en
> .
>

theworldinunion

unread,
Mar 7, 2010, 7:56:31 AM3/7/10
to pickle
Hi Ian,

Thanks for the quick reply and the clarification! I was baffled to see
line3 and line5 of my code pass, but now I see the reasoning behind
it.

cheers.

Reply all
Reply to author
Forward
0 new messages