PullMonkey Blog

02 Mar

Cucumber and Pickle - find_latest_model!


I've been working with cucumber, capybara and pickle quite a bit recently and came across a problem.

I wanted to be able to tag a record for later reuse.  The way pickle does this is to use find_model, which gets the very first record and associates this to the tag you use to name the record.

I want to get the latest record, the most recent record and tag that for reuse, there does not seem to be a way to do this currently.

So here is what I did.

Added this to my features/support/pickle.rb:

And can now use this as my step definition:

And now I have a reference I can use later for things like show and edit pages:

Then a product: "test" was just created
And I should be on product: "test"'s page

This has really helped my tests, maybe there is an alternative to having to do this?


Filed under: Uncategorized
  1. 2 Trackback(s)

  2. Fresh Cucumber » PullMonkey Blog » Blog Archive » Cucumber and Pickle …
  3. Pantsuits For Women

Sorry, comments for this entry are closed at this time.