Skip to content

Commit

Permalink
Adding factory girl and a few starter factories.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed Sep 20, 2008
1 parent a584583 commit cbe87af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/factories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

Factory.sequence(:id) { |n| n }
Factory.sequence(:email) { |n| "test_#{n}@domain.com" }
Factory.sequence(:title) { |n| "Report Title ##{n}" }

Factory.define :employee do |e|
e.name { "Factory Employee ##{Factory.next(:id)}" }
e.email { Factory.next(:email) }
end

Factory.define :report do |r|
r.title { Factory.next(:title) }
r.body 'Bla bla bla. Bla. Bla bla.'
end

Factory.define :employee_with_reports, :class => 'Employee' do |e|
e.reports do |reports|
[reports.association(:report), reports.associations(:report)]
end
end

1 change: 1 addition & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'quietbacktrace'
require 'mocha'
require File.join(File.dirname(__FILE__),'lib/boot') unless defined?(ActiveRecord)
require 'factory_girl'
require 'lib/test_case'
require 'grouped_scope'

Expand Down

0 comments on commit cbe87af

Please sign in to comment.