Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Cucumber step definitions to create model instances with dynamic attributes and associations.

tag: v0.1.4

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.rdoc

h1. featured_model

Warning! As reflected by the incredibly low version number, this is a new work in progress. We are sharing it with you early and often in the hope you will find it useful and help us make it better quicker.

We love using “fixjour”:github.com/nakajima/fixjour in RSpec for creating test instances of our models. featured_model allows us the same flexibility in Cucumber.

For example, doing this in RSpec: <pre>@address = create_address(:city => “Madison”, :state => “WI”, :zip_code => “53703”) @order = create_order(:status => “open”, :order_id_amazon => “1234”, :address => @address)</pre>

can be done in Cucumber as: <pre>Given a new address with city “Madison” and state “WI” and zip code “53703” And a new order with status “open” and order id amazon “1234” for address with city “Madison”</pre>

h2. Installation

coming soon...

h2. Usage

Start your call off with @“a new <model-name>”@ where @<model-name>@ is a lower case version of the class name you want to build with fixjour. Underscores can be replaced with spaces.

For example: <pre>Given a new address</pre>

| actual class name | @<model-name>@ | | Order | order | | LineItem | line item |

h3. Add attribute values

Add the first attribute to your call using the @'with'@ operator: <pre>Given a new address with city “Madison”</pre>

Add as many additional attributes as you want using the @'and'@ operator: <pre>Given a new address with city “Madison” and state “WI” and zip code “53703”</pre>

h3. Add associations

We specify the associated object using attributes, instead of ActiveRecord id numbers. This is more in the spirit of functional Cucumber testing to not depend on details an end user would not understand.

Use the @'for'@ operator to specify an association. You must give the association enough attributes to find the correct, desired associated object in the database.

In this example, we create a new order and setting its address to the address created on the line before. <pre>Given a new address with city “Madison” and state “WI” and zip code “53703” And a new order with status “open” and order id amazon “1234” for address with city “Madison”</pre>

Note how we did not have to specify all the attributes for the associated object. We just give the minimal attributes in order to find the correct object. In this case, city “Madison” is enough since there is no other address in the database with city set to “Madison”. If your test has more addresses in play, then you'll need to specify more attributes.

In other words, the example above can also be written as: <pre>Given a new address with city “Madison” and state “WI” and zip code “53703” And a new order with status “open” and order id amazon “1234” for address with city “Madison” and state “WI” and zip code “53703”</pre>

h2. Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but

    bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

h2. Contributors

listrophy bendycode coreyhaines arta randland

h2. Copyright

Copyright © 2009 bendyworks. See LICENSE for details.

Something went wrong with that request. Please try again.