Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 85 lines (68 sloc) 2.311 kb
f721bc6 @joshuaclayton Initial work on DeclarationList and cleaning up AttributeList
joshuaclayton authored
1 require "active_support/core_ext/module/delegation"
2
cbdc2ae @jferris Renamed Strategy to Proxy
jferris authored
3 require 'factory_girl/proxy'
5aea0f4 @jferris Use a registry class for keeping factories and sequences. Treat
jferris authored
4 require 'factory_girl/registry'
aee300a @joshuaclayton Add NullFactory
joshuaclayton authored
5 require 'factory_girl/null_factory'
6a553ca @jferris Created a project skeleton with the Factory class
jferris authored
6 require 'factory_girl/factory'
3eccbc5 @joshuaclayton Add AttributeAssigner to handle attribute assignment on the build class ...
joshuaclayton authored
7 require 'factory_girl/attribute_assigner'
b72c916 @joshuaclayton AnonymousEvaluator => EvaluatorClassDefiner
joshuaclayton authored
8 require 'factory_girl/evaluator'
9 require 'factory_girl/evaluator_class_definer'
03fa0d1 @jferris Refactored attributes into their own class
jferris authored
10 require 'factory_girl/attribute'
4d30663 @jferris Callbacks aren't attributes
jferris authored
11 require 'factory_girl/callback'
f721bc6 @joshuaclayton Initial work on DeclarationList and cleaning up AttributeList
joshuaclayton authored
12 require 'factory_girl/declaration_list'
a154e64 Introduce declarations
Joe Ferris and Josh Clayton authored
13 require 'factory_girl/declaration'
fa36b1d @jferris Added support for sequences
jferris authored
14 require 'factory_girl/sequence'
82746c2 @joshuaclayton Add attribute lists
joshuaclayton authored
15 require 'factory_girl/attribute_list'
1c74d9d @joshuaclayton Rename attribute groups to traits
joshuaclayton authored
16 require 'factory_girl/trait'
98e6c51 @jferris #12 - added attribute aliases
jferris authored
17 require 'factory_girl/aliases'
41bc3ac @joshuaclayton Add FactoryGirl::Definition
joshuaclayton authored
18 require 'factory_girl/definition'
ac8875c @jferris Extracted yielded object for dsl into a proxy; moved default public api ...
jferris authored
19 require 'factory_girl/definition_proxy'
9472a14 @joshuaclayton Move around requires
joshuaclayton authored
20 require 'factory_girl/syntax'
8b4a6a1 @jferris Moved definition loading syntax out of the factory class; moved everythi...
jferris authored
21 require 'factory_girl/find_definitions'
3798144 @joshuaclayton FactoryGirl.reload clears all registries and loads all known definitions
joshuaclayton authored
22 require 'factory_girl/reload'
4824125 @jferris Check for undefined constants/methods on Factory on FactoryGirl to prese...
jferris authored
23 require 'factory_girl/deprecated'
5c88bb0 @jferris Renamed Factory#factory_name to Factory#name; cleaned up Factory#human_n...
jferris authored
24 require 'factory_girl/version'
eb8b774 @jferris Fixed definition autoloading support for rails 2.x when config.gem is in...
jferris authored
25
26 if defined?(Rails) && Rails::VERSION::MAJOR == 2
27 require 'factory_girl/rails2'
28 end
29
c59981d @jferris Split factories/sequences into separate registries most of the time;
jferris authored
30 module FactoryGirl
1153783 @joshuaclayton More Factory reorganization and cleanup
joshuaclayton authored
31 # Raised when a factory is defined that attempts to instantiate itself.
32 class AssociationDefinitionError < RuntimeError; end
33
34 # Raised when a callback is defined that has an invalid name
35 class InvalidCallbackNameError < RuntimeError; end
36
37 # Raised when a factory is defined with the same name as a previously-defined factory.
38 class DuplicateDefinitionError < RuntimeError; end
39
c46c090 @joshuaclayton Consolidate errors into factory.rb
joshuaclayton authored
40 # Raised when calling Factory.sequence from a dynamic attribute block
41 class SequenceAbuseError < RuntimeError; end
42
43 # Raised when defining an invalid attribute:
44 # * Defining an attribute which has a name ending in "="
45 # * Defining an attribute with both a static and lazy value
46 # * Defining an attribute twice in the same factory
47 class AttributeDefinitionError < RuntimeError; end
48
c59981d @jferris Split factories/sequences into separate registries most of the time;
jferris authored
49 def self.factories
7fdf1a8 @joshuaclayton Registries are named
joshuaclayton authored
50 @factories ||= Registry.new("Factory")
c59981d @jferris Split factories/sequences into separate registries most of the time;
jferris authored
51 end
52
53 def self.register_factory(factory)
54 factories.add(factory)
55 end
56
57 def self.factory_by_name(name)
58 factories.find(name)
59 end
60
61 def self.sequences
7fdf1a8 @joshuaclayton Registries are named
joshuaclayton authored
62 @sequences ||= Registry.new("Sequence")
c59981d @jferris Split factories/sequences into separate registries most of the time;
jferris authored
63 end
64
65 def self.register_sequence(sequence)
66 sequences.add(sequence)
67 end
68
69 def self.sequence_by_name(name)
70 sequences.find(name)
71 end
a78bc2a @joshuaclayton WIP: initial cleanup
joshuaclayton authored
72
1c74d9d @joshuaclayton Rename attribute groups to traits
joshuaclayton authored
73 def self.traits
7fdf1a8 @joshuaclayton Registries are named
joshuaclayton authored
74 @traits ||= Registry.new("Trait")
3800888 @twalpole Add global attr_group support
twalpole authored
75 end
76
1c74d9d @joshuaclayton Rename attribute groups to traits
joshuaclayton authored
77 def self.register_trait(trait)
78 traits.add(trait)
3800888 @twalpole Add global attr_group support
twalpole authored
79 end
80
1c74d9d @joshuaclayton Rename attribute groups to traits
joshuaclayton authored
81 def self.trait_by_name(name)
82 traits.find(name)
3800888 @twalpole Add global attr_group support
twalpole authored
83 end
c59981d @jferris Split factories/sequences into separate registries most of the time;
jferris authored
84 end
Something went wrong with that request. Please try again.