Simple fixtures replacement for ActiveRecord
Ruby
Pull request Compare This branch is 30 commits behind soveran:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
extras
lib
rails
MIT-LICENSE
README.rdoc
spawner.gemspec

README.rdoc

Spawner

Spawner is a simple fixtures replacement. In the examples I use Faker to generate random data, but you can use any method.

Usage

With ActiveRecord:

class User < ActiveRecord::Base
  spawner do |user|
    user.name = Faker::Name.name
    user.email = Faker::Internet.email
  end
end

With Sequel:

class User < Sequel::Model
  extend Spawner

  spawner do |user|
    user.name = Faker::Name.name
    user.email = Faker::Internet.email
  end
end

If you don't want to pollute your class definition, you can of course use it from outside:

User.spawner do |user|
  user.name = Faker::Name.name
  user.email = Faker::Internet.email
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

$ 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.