2011/11/18 Norbert Melzer <[email protected]>: > But how can I avoid this problem, without completely rewriting all > code that depends on my model?
I posted this on the github site also, there I was advised to use `::Factory` inside my code whenever I am refering my own model. Since this is a problem that occurs only in testenv, but I have to change my overall code, I dislike that solution, what brings me to... > Or alternatively, are there any similar things like Factory_girl that > will not have that collision with my own code? ... another gem I stumbled upon yesterday, "Fabrication" (<http://fabricationgem.org/>). This does mostly the same as factory_girl does, and adds some spice. It is capable of generating cucumbersteps which makes creation of objects in my features a lot easier, also I can use properties of the fabricated model inside of the fabricator without to build them in a variable first (a thing I missed in factory girl) While I had to do following in FG Factory.define :user do |user| user_name = Factory.next(:name) # Just imagine I had used inlinesequence at this point :) user.name "#{user_name}" user.email "#{user_name}@example.com" user.password "secret" end I can do the following in Fabricatiion: Fabricator(:user) do name { sequence { |n| "User#{n}" } } email { |user| "#{user.name.downcase.parameterize}@example.com" } password "secret" end This is from a privat project, where I am converting my Factorys to Fabricators, also I converted all sequences to inline where possible (this is something I had done with FG soon too) I hope this one helps others too! Bye Norbert -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

