-
Notifications
You must be signed in to change notification settings - Fork 134
Home
This wiki is for Machinist 2, which is currently in pre-pre-release mode. For Machinist 1 information, see the readme.
(These installation instructions are for Rails 3. For other installation options, see the Installation page.)
In your app’s Gemfile
, in the group :test
section, add:
gem 'machinist', '2.0.0.head', :git => 'git://github.com/notahat/machinist.git', :branch => 'machinist2'
Then run:
bundle install
rails generate machinist:install
Learn more about Installation
A blueprint tells Machinist how to generate an object. The blueprint take care of making up values for attributes that you don’t care about in your test, leaving you to focus on the just the things that you’re testing.
Post.blueprint do
title { "A Post" }
body { "Lorem ipsum..." }
end
Blueprints live in your test/blueprint.rb
(or spec/support/blueprints.rb
) file.
Learn more about Blueprints
Once you’ve defined a blueprint for a class, you can construct an object of that class with:
Post.make
To override attributes in the blueprint, pass them in as a hash:
Post.make(:title => "Special Title")
Learn more about Make