Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bendyworks/featured_model
Cucumber step definitions to create model instances with dynamic attributes and associations.
https://github.com/bendyworks/featured_model
Last synced: 28 days ago
JSON representation
Cucumber step definitions to create model instances with dynamic attributes and associations.
- Host: GitHub
- URL: https://github.com/bendyworks/featured_model
- Owner: bendyworks
- License: mit
- Created: 2009-10-06T14:33:46.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2010-03-17T20:53:48.000Z (almost 15 years ago)
- Last Synced: 2024-04-24T20:28:21.732Z (8 months ago)
- Language: Ruby
- Homepage:
- Size: 102 KB
- Stars: 7
- Watchers: 19
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.rdoc
- License: LICENSE
Awesome Lists containing this project
README
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 "@ where @@ is a lower case version of the class name you want to build with fixjour. Underscores can be replaced with spaces.
For example:
Given a new address| actual class name | @@ |
| Order | order |
| LineItem | line item |h3. Add attribute values
Add the first attribute to your call using the @'with'@ operator:
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
randlandh2. Copyright
Copyright (c) 2009 bendyworks. See LICENSE for details.