使用机械师而不是固定装置

在我的Rails 3应用程序中,我有一个带有以下字段的User模型
   name: string
   email: string
   children: has_many association to another model
我正在使用机械师2来生成模拟数据,它的蓝图看起来像
User.blueprint do
   name { 'user{sn}' }
   email { '{object.name}@domain.com' }
end
用户单元测试:
require 'test_helper'

class UserTest < ActiveSupport::TestCase
  should have_many( :children )
  should validate_uniqueness_of( :email )
  should_not allow_value("blah").for(:email)
  should_not allow_value("b lah").for(:email)
  should allow_value("a@b.com").for(:email)
  should allow_value("asdf@asdf.com").for(:email)
end
当我生成用户模型时,它创建了一个fixture文件。我的理解是,当我运行
rake
时,Rails使用该fixture文件生成测试中使用的对象。这不是我想要的。我希望Rails能够无缝地使用机械师的蓝图,因为它使用了夹具文件。 有没有办法做到这一点?有没有办法告诉rails它需要使用蓝图而不是灯具?     
已邀请:
将其添加到config / application.rb:
config.generators do |g|
  g.fixture_replacement :machinist
end
您也可以安全地丢弃旧的灯具文件夹,除非您想要明显地保留它们!     

要回复问题请先登录注册