Named Blueprints with factory_girl

Posted by Jason Nerer on Stack Overflow See other posts from Stack Overflow or by Jason Nerer
Published on 2010-05-05T20:21:48Z Indexed on 2010/05/05 21:18 UTC
Read the original article Hit count: 383

I am using Factory Girl but like the machinist syntax. So I wonder, if there is any way creating a named blueprint for class, so that I can have something like that:

User.blueprint(:no_discount_user) do
  admin           false
  hashed_password "226bc1eca359a09f5f1b96e26efeb4bb1aeae383"
  is_trader       false
  name            "foolish"
  salt            "21746899800.223524289203464"
end

User.blueprint(:discount_user) do
  admin           false
  hashed_password "226bc1eca359a09f5f1b96e26efeb4bb1aeae383"
  is_trader       true
  name            "deadbeef"
  salt            "21746899800.223524289203464"
  discount_rate { DiscountRate.make(:rate => 20.00) }
end

DiscountRate.blueprint do
  rate {10}
  not_before ...
  not_after ...
end

Is there a way making factory_girl with machinist syntax acting like that? I did not find one. Help appreciated.

Thx in advance Jason

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about factorygirl