Skip to content

Commit

Permalink
Move the named machinist blueprint examples to the API section of the…
Browse files Browse the repository at this point in the history
… documentation.
  • Loading branch information
chrisdarroch committed Aug 1, 2010
1 parent 0a7c744 commit f9a7176
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,6 @@ In your <tt>features/support/env.rb</tt> add the following lines at the bottom
require "#{Rails.root}/spec/blueprints" # or wherever they live
Before { Sham.reset } # reset Shams in between scenarios

The latest version of pickle supports {named blueprints}[http://github.com/notahat/machinist/commit/d6492e6927a8aa1819926e48b22377171fd20496].

Following from the previous example, if you had the following blueprints for your User models

User.blueprint do
name
email
end

User.blueprint(:super_admin) do
role { "admin" }
end

You could create a super-admin user with pickle by simply adding the name of the blueprint before the model:

Given a super admin user exists


This is much nicer than having to set up common configurations in your steps all the time, and far more readable to boot.

==== FactoryGirl: make sure factories are loaded

In your config/environments/cucumber.rb file, make sure the factory-girl gem is included (unless it's installed as a plugin).
Expand Down Expand Up @@ -204,6 +184,35 @@ You can refer to other models in the fields
| Fred | false |
| Ethel | true |

===== Named machinist blueprints

"Given <b> a <i>named</i> model</b> exists with <b>fields</b>"

The latest version of pickle supports {named machinist blueprints}[http://github.com/notahat/machinist/commit/d6492e6927a8aa1819926e48b22377171fd20496].

If you had the following blueprints:

User.blueprint do
name
email
end

User.blueprint(:super_admin) do
role { "admin" }
end

User.blueprint(:activated) do
activated { true }
end

You could create a user with pickle by simply adding the name of the blueprint before the model:

Given a super admin user exists
And an activated user exists with name: "Fred"

This is much nicer than having to set up common configurations in your steps all the time, and far more readable to boot.


==== Then steps

===== Asserting existence of models
Expand Down

0 comments on commit f9a7176

Please sign in to comment.