I like to use Sham gem . As long as you have a fickle model that matches some elements of the base implementation, you should be fine. For example, in my Rails application, I would do the following:
class Dog::Sham
def self.options
{ name: "Barney" }
end
end
class Dog < Struct.new(:name)
def self.create options
self.new(options[:name])
end
end
Then in the console, I can create a factory Dog using the sham command:
Sham::Config.activate!
Dog.sham!
=> #<struct Dog name="Barney">
source
share