Michael MacDonald

Pickle Tables

In Rails, Testing on November 26, 2009 at 12:12 am

Following on from my original and followup articles on using Pickle with Cucumber, a brand new version of Pickle is now available. Version 0.2.0 now gives you the ability to use Pickle with Cucumber’s multiline step argument tables. This means you can now do the following with Pickle:

Given a company exists
And another company: "rubyflare" exists
And the following people exist:
  | name  | age | employed | company              |
  | Digby | 13  | false    | the first company    |
  | Ethyl | 27  | true     | company: "rubyflare" |
Then the following people should exist:
  | name  | age |
  | Digby | 13  |
  | Ethyl | 27  |
And the 2nd person should be one of company: "rubyflare"'s employees

You can quickly create multiple objects in an easy to read fashion rather than filling your scenarios with multiple lines of “an another user exists …”. As an added bonus you can also use Pickle references within these tables. In the example above, we are creating new people objects and associating them to the companies using the Pickle references for these company objects.

Again, I’ll just point out that the above example required no custom step definitions. I didn’t have to write any step definitions! Pickle takes care of the grunt work leaving you free to focus on your domain specific scenario steps.

Other recent improvements with Pickle include:

  • an email helper for mapping names to email addresses similar to paths
  • its own separate configuration file (pickle.rb) – pickle no longer adds code to features/support/env.rb

I’ve also updated my pickle_example project to the latest version and have added the above example scenario. Feel free to clone it and use it to explore the benefits of using Pickle.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: