Spawner
Spawner is a simple fixtures replacement. In the examples I use Faker to generate random data, but you can use any method.
Usage
class User < ActiveRecord::Base
spawner do |user|
user.name = Faker::Name.name
user.email = Faker::Internet.email
end
end
Then, in your test or in any other place:
@user = User.spawn
Or, if you need something special:
@user = User.spawn do |user|
user.name = "Michel Martens"
end
Or even this:
@user = User.spawn :name => "Michel Martens"
Installation
You can install it as a Rails plugin or as a gem:
$ gem sources -a http://gems.github.com (you only have to do this once)
$ sudo gem install soveran-spawner
Thanks
Thanks to Foca (github.com/foca/) for his suggestions and Pedro (github.com/peterpunk/) for the gemspec.
Copyright © 2008 Michel Martens for CitrusByte (www.citrusbyte.com). Released under the MIT license.