Machinist is a factory framework for building test objects in Ruby. It's made to be a drop-in replacement for fixtures in Ruby on Rails testing suites.
Questions tagged [machinist]
34 questions
2
votes
2 answers
Machinist for Non-ActiveRecord Models
Is it possible to use Machinist to create blueprints for non-activerecord models? Seems to generate an error no matter what I try!
If this is impossible with Machinist, is there another fixture generating gem that can do it? I've also read that…

joeellis
- 2,745
- 7
- 28
- 45
2
votes
2 answers
How to use named Machinist blueprints in Cucumber with Pickle
I noticed this little tid-bit in the readme for pickle:
(The latest version of pickle supports multiple
blueprints, for earlier versions of machinist use pickle <= 0.1.10)
I'm running in to a situation where I want to create a user with admin…

Chris
- 9,994
- 3
- 29
- 31
2
votes
1 answer
How do I get cucumber and pickle working with mongo_mapper, machinist, and machinist_mongo?
I would like to get machinist, machinist_mongo, mongo_mapper, cucumber and pickle to play nice together.
Currently I have machinist with all my blueprints configured and am using cucumber to do BDD. So far so good. My problem is I am having to write…

Nate Pinchot
- 3,288
- 24
- 35
2
votes
0 answers
ArgumentError with Cucumber and Machinist
I am using Cucumber Factory and to make it easy to use Machinist with Cucumber and I am running into an ArgumentError. The line in my feature file that is causing the problem is:
Given there is a tag
In the blueprint file I define Tag as this (not…

Andreas
- 638
- 2
- 8
- 14
1
vote
1 answer
rails 3.2 and machinist issues
I've just upgraded to Rails 3.2.1 with Ruby 1.9.3-p0 and I'm using Machinist 2.0. Before updating a large project all my tests passed. The problem I"m having is when I create a blueprint within a 'let' call in my rspec tests and then refer to it in…

map7
- 5,096
- 6
- 65
- 128
1
vote
0 answers
Machinist2 and dirty tracking
Unfortunately, it seems that Machinist in cooperation with Active Record somehow bypasses dirty tracking. While I have test based on after_save callback, the tracked attribute must be set explicitely, otherwise tracked_changed? returns false... Does…

papricek
- 103
- 4
1
vote
1 answer
Passing in non-attribute values to Machinist blueprint
This is a simplified example of what I'm trying to do...
Suppose I had an object Person:
Person.blueprint do
name
age
end
I want to be able to do something like this:
Person.blueprint(:from_birthdate) do
name
age { Time.now - birthdate…

Karl
- 6,035
- 5
- 30
- 39
1
vote
1 answer
Inheriting attributes in Machinist blueprints
Using Machinist, is there some way one can define blueprints such that they inherit attributes from other blueprints? I've looked at all the documentation and examples I've found, but I haven't seen it happening.
I want to do something like…

u2622
- 2,991
- 3
- 25
- 27
1
vote
1 answer
Using machinist instead of fixtures
In my Rails 3 application, I have a User model with the following fields
name: string
email: string
children: has_many association to another model
I'm using machinist 2 to generate mock data, its blueprint looks like
User.blueprint do
…

Stefan
- 9,289
- 7
- 38
- 46
1
vote
2 answers
Mongoid with Machinist
I am using machinist and mongoid. How can I generate blueprint for embeds_many association. Mongoid embeds_many association embeds the hash of array. So I just started like this:
User.blueprint do
address { :address1 => "address", :address2 =>…

kriysna
- 6,118
- 7
- 30
- 30
1
vote
1 answer
How to get nested attributes hash with machinist?
so I'm trying to write some controller tests for quite complex nested form. I have machinist which works fine for model tests but I can't get a nested hash out of it to use for a post request in controller test.
What is a best way to handle this?

Dabrorius
- 1,039
- 1
- 8
- 17
0
votes
1 answer
Rails fixtures with a ruby script
Fixtures, factories, ... etc don't execute the real create() method. For instance, when an user is created, I generate a Preference object for him. But with fixtures I have to do it manually.
So could I do it with a script like all of my…

Dorian
- 22,759
- 8
- 120
- 116
0
votes
1 answer
Rails 2.3.8 machinist undefined method make?
I'm working on an old Rails 2.3.8 which doesn't have any testing and I'm trying to add some tests using rspec with machinist to the app.
I've installed rspec 1.3.0 & 1.3.2 and ran the generator script.
I followed the instructions…

map7
- 5,096
- 6
- 65
- 128
0
votes
1 answer
Machinist Blueprint when model belongs to 2 has_many associations
Environment: Ruby 1.9.2, Rails 3.1, Machinist 2
I have a Transaction model which belongs to both an Account and Category.
class Transaction < ActiveRecord::Base
belongs_to :account
belongs_to :category
validates_presence_of :account_id,…

dmin
- 136
- 3
0
votes
1 answer
Machinist + Cabybara + Test::Unit = blueprints missing
I've run into a very confusing problem...
All my tests pass when i run them in isolation.
When I run them like rake test, after my integration tests run, Machinist says that it can't find blueprints anymore.
To get the capybara tests working I have…

Brad Langhorst
- 53
- 4