…no, not because it leaves a bitter aftertaste, I’m talking about the Pickle step definitions for Cucumber.
I have lately been using Pickle when writing Cucumber features, however I have come to the conclusion that this is a bad idea. The reason being that when using Pickle, you create entries directly, whereas the whole point of Cucumber is that it is for high level integration testing.
What I do now, is to create any entries by filling out and submitting the relevant forms with a step definition, for example I may have the following:
Given an admin has created the following products | Name | Variants | Featured | | T-Shirt | Small: 10.99, Medium: 12.99, Large: 14.99 | Yes | | Keyring | Default: 2.99 | Yes |
I would then write a step definition for this that would log in as the admin user, break this table apart and fill in the relevant forms.
I would go so far as to say that using factories at all in features is a bad idea and instead everything should happen via the user interface for better coverage. For any data that is known to exist when the app is deployed via ‘rake db:seed’, this can be loaded in the ‘env.rb’ file e.g.
Update 11/2/2010: Sometimes this is simply not practical due to slowdown which is a shame, as noted by Amos in the comments.