Skip to content

Instantly share code, notes, and snippets.

@lmarburger
Created January 4, 2009 23:43
Show Gist options
  • Save lmarburger/43216 to your computer and use it in GitHub Desktop.
Save lmarburger/43216 to your computer and use it in GitHub Desktop.
module Test #:nodoc:
module Unit #:nodoc:
class TestCase #:nodoc:
class << self
def factories(*names)
names.each { |name| load_factory(name) }
end
private
def load_factory(name)
module_eval <<-EVAL, __FILE__, __LINE__
require 'factories/#{name}_factory'
include #{name.to_s.camelize}Factory
EVAL
end
end
end
end
end
module PeopleFactory
def get_person_mock(options = {})
Person.new({ :id => 1, :first_name => 'Larry', :last_name => 'Marburger' }.merge(options))
end
end
class Test::Unit::TestCase
factories :people
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment