1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
Commit graph

22 commits

Author SHA1 Message Date
Joshua Clayton
7b2fbeac5c Add AssociationRunner for running associations from strategies
This extracts logic for running factories based on name and either
strategy class, symbol representing a strategy, or nil (defaulting to
the create strategy)
2012-02-10 18:19:17 -05:00
Joshua Clayton
b79a525c09 Proxy => Strategy 2012-02-10 18:19:17 -05:00
Gabe Berke-Williams
b63e3896fc Remove unnecessary call to #should. 2012-02-07 23:06:59 -05:00
Joshua Clayton
9347873c80 Clean up proxy specs 2011-12-30 00:41:50 -05:00
Joshua Clayton
e2f663358a Clean up attributes_for spec 2011-12-30 00:41:50 -05:00
Joshua Clayton
d3a7b7e065 Remove #set_ignored altogether 2011-11-30 22:13:55 -05:00
Joshua Clayton
3282eea658 Move class creation/handling to an anonymous evaluator
This allows for Attribute#to_proc to not require a proxy to be passed to
return a Proc. It also allows for removal of Attribute#add_to
2011-11-30 20:56:58 -05:00
Joshua Clayton
b339c8f109 Move all block execution for dynamic attributes to the anonymous_instance 2011-11-28 22:52:54 -05:00
Joshua Clayton
fba6f332fd Attributes have a to_proc method and are lazily evaluated on an
anonymous class
2011-11-25 21:59:43 -05:00
Joshua Clayton
5bbbcb9edf Move logic of what to do to create an instance to the definition where it belongs 2011-11-25 18:07:06 -05:00
Joshua Clayton
3ed2f6274a Remove associate method from all the FactoryGirl::Proxy subclasses 2011-11-18 18:39:21 -05:00
Joshua Clayton
3114dcd935 Wrap up DeclarationList
DeclarationList knows how to generate an attribute
list, which never really made sense outside of being generated from
declarations. Now, the declaration list builds a list of attributes
which is combined in Factory#attributes with attributes from traits and
its parents.
2011-10-31 19:05:34 -04:00
Joshua Clayton
41bc3ac5ff Add FactoryGirl::Definition
Both Factory and Trait have similar methods and interact with a
DefinitionProxy. The idea here is to move the interface DefinitionProxy
expects to a separate class and both Factory and Trait can delegate to
an instance of Definition.
2011-10-30 23:17:03 -04:00
Joshua Clayton
8f4e052a85 Proxies are always instantiated with callbacks 2011-10-20 14:19:09 -04:00
Joshua Clayton
6e9baa767f Maintain abstraction consistency within definition_proxy 2011-10-14 22:50:37 -04:00
Joshua Clayton
180eb8bec7 Refactor definition_proxy_spec
This introduces a couple of things: firstly, there's now a MockFactory
that allows for introspection instead of spying all over the place. This
should make tests a lot less brittle. Secondly, a couple of handy
matchers have been made available to perform assertions against the
mock.
2011-10-14 17:21:29 -04:00
Joshua Clayton
dc32fd69e8 Change syntax for ignoring attributes to use block syntax instead of
calling ignore on individual declarations.

Old syntax:

    factory :user do
      rockstar(true).ignore
      four { 2 + 2 }.ignore

      name { "John Doe#{" - Rockstar" if rockstar}" }
    end

New syntax:

    factory :user do
      ignore do
        rockstar true
        four     { 2 + 2 }
      end

      name { "John Doe#{" - Rockstar" if rockstar}" }
    end
2011-10-09 16:46:57 -04:00
Joe Ferris
0f87ca3aa9 Use objects, not structs 2011-09-16 17:48:06 -04:00
Jim Kingdon
90374818a7 Now able to specify :method => :build in a factory's association.
See issue #64.
2011-08-25 15:11:01 -04:00
Joshua Clayton
c87429b829 Add transient variables
Closes #142
Closes #103
2011-08-20 18:36:37 -04:00
Joshua Clayton
d296a22586 Clean up proxy specs with shared examples 2011-08-19 17:21:55 -04:00
Joshua Clayton
0b2c4da0a4 Move DefineConstant code into macro 2011-08-19 17:21:54 -04:00