Cucumber Factory - create ActiveRecord objects without step definitions
Cucumber Factory allows you to create ActiveRecord objects directly from your Cucumber features. No step definitions required.
Install the gem:
sudo gem sources -a http://gems.github.com sudo gem install makandra-cucumber_factory
Add the following to your Initializer.run block in your environment.rb:
config.gem 'makandra_cucumber_factory', :lib => 'cucumber_factory', :source => 'http://gems.github.com'
Create a step definition stub in <tt>features/step_definitions/factory_steps.rb, which just says
The following will call Movie.make, Movie.create! or Movie.new, depending on what's available:
Given there is a movie
To create a new record with attributes set, you can say:
Given there is a movie with the title "Sunshine" and the year "2007"
The following will also store the created record in @sunshine:
Given "Sunshine" is a movie with the title "Sunshine" and the year "2007"
To set associations you can refer to other records by name:
Given "Before Sunrise" is a movie And "Before Sunset" is a movie with the prequel "Before Sunrise"
You can also refer to the last created object of a kind by saying “above”:
Given there is a movie with the title "Before Sunrise" And "Before Sunset" is a movie with the prequel above