Pickle(?) and factory_girl with table values the same as factory names

18 views
Skip to first unread message

Doug

unread,
Jun 5, 2011, 8:21:52 PM6/5/11
to pickle
I'm using cucumber (0.10.3), cucumber-rails (0.5.1), factory_girl
(1.3.3), factory_girl_rails (1.0.1), and pickle (0.4.7).

If I have an application with the classes FruitBasket and Apple and
corresponding factories, the following does not behave as I expect:

Background:
Given the following fruit_baskets exists:
| fruit_name | fruit_count |
| banana | 3 |
| apple | 4 |
| cherry | 20 |

If I don't have the row with "apple" in it, it works fine, fruit_name
is set to "banana" and "cherry". It appears that pickle is assuming
that "apple" is the factory and not the string "apple", which is what
I want.

Is it pickle that's doing this? Is there a way to force pickle to use
the string "apple" and not invoke the factory?

Thanks.
Doug

Ian White

unread,
Jun 6, 2011, 5:05:41 AM6/6/11
to pickle-...@googlegroups.com
Hi Doug,

I believe that you culd enclose the strirng in quotes to get the desired effect.

| fruit_name | fruit_count |
| "banana" | | 3 |

Cheers,
Ian

> --
> 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.
>

Doug

unread,
Jun 6, 2011, 9:07:02 AM6/6/11
to pickle
Enclosing the string in quotes stored the quotes in the database:

>>>>>>>
Feature: Users should be able to create a fruit basket

Background: # features/
fruit_basket.feature:3
Given the following fruit_baskets exists: # features/
step_definitions/pickle_steps.rb:14
| fruit_name | fruit_count |
| "banana" | 3 |
| "apple" | 4 |
| "cherry" | 20 |

Scenario: create a fruit basket # features/
fruit_basket.feature:10
Given I retrieve the first fruit_basket # features/
step_definitions/application_steps.rb:1
Then that fruit_basket should have fruit name "banana" # features/
step_definitions/application_steps.rb:5
expected: "banana"
got: "\"banana\"" (using ==)
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/application_steps.rb:6:in `/^that
fruit_basket should have fruit name "([^"]*)"$/'
features/fruit_basket.feature:12:in `Then that fruit_basket
should have fruit name "banana"'

Failing Scenarios:
cucumber features/fruit_basket.feature:10 # Scenario: create a fruit
basket

1 scenario (1 failed)
3 steps (1 failed, 2 passed)
0m1.433s

Everton Moreth

unread,
Jun 7, 2011, 9:40:31 PM6/7/11
to pickle-...@googlegroups.com
Can you paste the error when trying to deal with the apple example?

Everton
Reply all
Reply to author
Forward
0 new messages