public
Rubygem
Description: Simple fixtures replacement for ActiveRecord
Clone URL: git://github.com/soveran/spawner.git
name age message
file MIT-LICENSE Tue Jun 10 21:01:26 -0700 2008 First commit [soveran]
file README.rdoc Sun Aug 24 21:11:28 -0700 2008 Changed README.rdoc and fixed gemspec [soveran]
directory extras/ Wed Jul 02 11:27:54 -0700 2008 Added sample rake task to extras [soveran]
file init.rb Wed Jun 11 13:18:41 -0700 2008 Removed ^M from ruby files [soveran]
directory lib/ Wed Jun 11 13:18:41 -0700 2008 Removed ^M from ruby files [soveran]
file spawner.gemspec Sun Sep 07 14:20:29 -0700 2008 Changed date in gemspec [soveran]
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

  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 (http://github.com/foca/) for his suggestions and Pedro (http://github.com/peterpunk/) for the gemspec.

Copyright © 2008 Michel Martens for CitrusByte (http://www.citrusbyte.com). Released under the MIT license.