OSDN Git Service

Regular updates
[twpd/master.git] / machinist.md
1 ---
2 title: Machinist
3 category: Ruby libraries
4 layout: 2017/sheet
5 tags: [Archived]
6 archived: Machinist has not been in active development since 2013.
7 ---
8
9 ### About
10
11 Machinist is a fixture management library for Ruby.
12
13 - <https://github.com/notahat/machinist>
14
15 ### Installing
16
17     # Gemfile
18     gem 'machinist', '>= 2.0.0.beta2', group: 'test'
19
20     # ~$ bundle
21     # ~$ rails generate machinist:install
22
23 ### Building objects
24
25     User.make
26
27     # `make` builds it, and `make!` builds+saves it
28     User.make!
29     User.make! name: "David"
30     User.make!(:admin)
31
32 ### Defining blueprints
33
34     User.blueprint do
35       name  { "User #{sn}" }
36       email { "user-#{sn}@example.com" }
37     end
38
39     User.blueprint(:admin) do
40       name  { "Admin User #{sn}" }
41       admin { true }
42     end
43
44 ### Associations
45
46     Post.blueprint do
47       author { User.make }
48
49       comments(3)    # Makes 3 comments (has_many / habtm)
50
51       author         # autodetect (Assumes there's User.blueprint)
52
53     end
54
55 ### References
56
57  * [https://github.com/notahat/machinist](https://github.com/notahat/machinist)