1
0
mirror of https://github.com/onkelbeh/cheatsheets.git synced 2025-10-16 07:28:25 +02:00
cheatsheets/machinist.md
Rico Sta. Cruz 511de900ba
Formatting updates (#2133)
- Update some sheets which have very long sections
- Remove `layout: 2017/sheet` (everything has the same layout now)
- Remove outdated sheets
2024-04-03 18:30:24 +11:00

1.0 KiB

title, category, tags, archived
title category tags archived
Machinist Ruby libraries
Archived
Machinist has not been in active development since 2013.

About

Machinist is a fixture management library for Ruby.

Installing

# Gemfile
gem 'machinist', '>= 2.0.0.beta2', group: 'test'

# ~$ bundle
# ~$ rails generate machinist:install

Building objects

User.make

# `make` builds it, and `make!` builds+saves it
User.make!
User.make! name: "David"
User.make!(:admin)

Defining blueprints

User.blueprint do
  name  { "User #{sn}" }
  email { "user-#{sn}@example.com" }
end

User.blueprint(:admin) do
  name  { "Admin User #{sn}" }
  admin { true }
end

Associations

Post.blueprint do
  author { User.make }

  comments(3)    # Makes 3 comments (has_many / habtm)

  author         # autodetect (Assumes there's User.blueprint)

end

References