Setup
The easiest way to install this gem is simply adding this line to your Gemfile:
If you’re not using bundler, then you can install it through command line
Blueprints boy is activated by calling BlueprintsBoy.enable at the bottom of your spec_helper/test_helper.
Blueprints file
Blueprints file is the file that contains all definitions of blueprints. This can either be single file or whole folder if you have many blueprints.
By default blueprints are searched in these files in this particular order in application root (which is either Rails.root if it’s defined or current folder by default):
- blueprints.rb
- blueprints/*.rb
- spec/blueprints.rb
- spec/blueprints/*.rb
- test/blueprints.rb
- test/blueprints/*.rb
You can set root option to override application root and filename option to pass custom filename pattern. For more information see configuration
Basic definitions
Basic definitions of blueprints look like this:
Note that in :fruitbowl blueprint we define depenendencies on other blueprints, meaning that once we build :fruitbowl, then :apple, :orange and all their dependencies will also be built.
Usage
You can use your defined blueprints in specs(tests) like this:
Whatever your blueprint block returns can be reached using method with the same name as blueprint.
All blueprints are built only once, so:
Advanced Usage
Its just ruby, right? So go nuts: