Machinist 2 - notahat/machinist GitHub Wiki

What’s New?

Machinist is now much simpler and cleaner. Sham is gone entirely.

Upgrading

Machinist 2 is not a drop-in replacement for Machinist 1. The API has changed, so you’ll need to go through your code and do the following:

- Replace calls to make with calls to make!, except within your blueprints.
- Replace calls to make_unsaved with calls to make.
- Delete all your Sham definitions, and provide explicit attribute values in all your blueprints.

All attributes must be specified in blocks, even if they are constant:

User.blueprint do
  username "default_name"     # Machinist 1
  username { "default_name" } # Machinist 2
end

For attributes with uniqueness constraints, you’ll need to use serial numbers:

User.blueprint do
  username { "user-#{sn}" }
end

If you need to refer to previous attributes from within a blueprint, you now have to use object:

Post.blueprint do
  title { "Post #{sn}" }
  body  { "Body for #{object.title}" }
end

What’s Missing?

- There’s no make method on ActiveRecord associations (yet) — Update: make on associations appears to be working for me as of 2.0 final, but will not automatically set the association to point to the original object. i.e. @user.posts.make! will create a new Post object, but that new post’s user association will not be set to @user – it will create a new user per its blueprint and set it to that.
- There’s no support for ORMs other than ActiveRecord (yet)

⚠️ **GitHub.com Fallback** ⚠️