Created
January 4, 2009 23:43
-
-
Save lmarburger/43216 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PeopleFactory | |
def get_person_mock(options = {}) | |
Person.new({ :id => 1, :first_name => 'Larry', :last_name => 'Marburger' }.merge(options)) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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