mini_factory is simple factory builder

Put following line in your test enviroment file: config.gem ‘daeltar-mini_factory’, :source => ‘gems.github.com’, :lib => ‘mini_factory’

Create some factories under Rails test directory in file called factories.rb:

Factory.define :account do { :login => “alexis”, :password => “topsecret” } end

Example usage of factory in your tests:

test “xml” do xml = Factory.build(:account).to_xml # build but not save object assert !xml.include?(“account-id”) end

test “should authenticate user” do account = Factory.create(:account) # creates and save object assert_equal Account.authenticate(‘alexis’, ‘topsecret’), account

end

test “should create account” do assert_difference(‘Account.count’) do post :create, :account => Factory.attributes_for(:account) # returns hash end end