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":http://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:
@address = create_address(:city => "Madison", :state => "WI", :zip_code => "53703") @order = create_order(:status => "open", :order_id_amazon => "1234", :address => @address)can be done in Cucumber as:
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"h2. Installation coming soon... h2. Usage Start your call off with @"a new
Given a new address| actual class name | @
Given a new address with city "Madison"Add as many additional attributes as you want using the @'and'@ operator:
Given a new address with city "Madison" and state "WI" and zip code "53703"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.
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"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:
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"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 (c) 2009 bendyworks. See LICENSE for details.