Permalink
Commits on Jun 11, 2012
  1. Bump version to 3.4.0

    joshuaclayton committed Jun 11, 2012
Commits on Jun 9, 2012
  1. Support refering to factory based on class name

    Allows for build/creating based on RSpec's described_class, useful since
    we've deprecated other syntaxes from FG.
    
    Closes #386
    joshuaclayton committed Jun 9, 2012
Commits on Jun 8, 2012
Commits on May 18, 2012
  1. Get spec passing on 1.9.2

    joshuaclayton committed May 18, 2012
  2. Optionally disable duplicate assignment of attributes in initialize_with

    By setting:
    
        FactoryGirl.duplicate_attribute_assignment_from_initialize_with =
    false
    
    This turns off duplicate assignment of attributes accessed from
    initialize_with. This means any attributes accessed from the factory and
    assigned in the initialize_with block won't be subsequently set after
    the object has been instantiated.
    
    This will be the default functionality in 4.0.
    
    Closes #345
    joshuaclayton committed May 18, 2012
  3. Remove unnecessary conditional in Evaluator#method_missing

    Evaluator has all methods defined dynamically; this includes standard
    attributes AND overrides. Because of this, method_missing never actually
    gets used to retrieve a value from previously declared attributes or
    overrides.
    
    This branch of logic was never accessed
    joshuaclayton committed May 18, 2012
Commits on May 13, 2012
  1. Sequences support Enumerators

    This introduces an EnumeratorAdapter so everything coming in looks like
    an Enumerator. It doesn't use the adapter if the #peek method exists on
    the object.
    
    This allows for sequences like:
    
        sequence(:cities, %w[Boston Atlanta Detroit Seattle].cycle)
    
    This also makes it easier to cycle through arrays and ranges, since they
    can be converted to Enumerators rather easily.
    
        sequence(:month, (1..12).to_enum)
        sequence(:month, %w[foo bar baz].to_enum)
    
    This doesn't handle when calling Range#step out of the box, because
    Ruby returns an Enumerator but ActiveSupport 3.x returns an array,
    meaning #to_enum still needs to be called.
    
    Closes #339, #378
    joshuaclayton committed May 13, 2012
  2. Bump version to 3.3.0

    joshuaclayton committed May 13, 2012
Commits on May 12, 2012
  1. Styles

    joshuaclayton committed May 12, 2012
  2. Allow initialize_with defined for all factories

    This allows users to define initialize_with for every factory run through
    factory_girl.
    
        FactoryGirl.define do
          initialize_with { new("John Doe") }
        end
    
    If you want to override this default, set it per factory or in a trait
    (and include the trait).
    
    Closes #342
    joshuaclayton committed May 12, 2012
  3. Allow to_create defined for all factories

    This allows users to define to_create for every factory run through
    factory_girl.
    
        FactoryGirl.define do
          to_create {|instance| instance.persist! }
        end
    
    If you want to override this default, set it per factory or in a trait
    (and include the trait).
    
    Closes #341
    joshuaclayton committed May 12, 2012
Commits on May 11, 2012
  1. Fix deprecation messages

    Closes #375
    joshuaclayton committed May 11, 2012
Commits on May 6, 2012
Commits on May 5, 2012
  1. More style tweaks

    joshuaclayton committed May 5, 2012
  2. Cleanup

    joshuaclayton committed May 5, 2012
  3. Clean up documentation

    joshuaclayton committed May 5, 2012
  4. Style cleanup

    joshuaclayton committed May 5, 2012
  5. Style cleanup

    joshuaclayton committed May 5, 2012
Commits on May 4, 2012
  1. Introduce new callback syntax

    Instead of calling before_create, after_build, after_create, or
    after_stub, you can now call:
    
        before(:create) {|instance| instance.name = "overridden!" }
        after(:create)  {|instance| instance.name = "overridden!" }
        after(:build)   {|instance| instance.name = "overridden!" }
        after(:stub)    {|instance| instance.name = "overridden!" }
    
    Additionally, you can declare callbacks longhand:
    
        callback(:after_stub) {|instance| instance.name = "overridden!" }
    
    This allows for custom callbacks to be defined:
    
        callback(:custom_callback) {|instance| instance.name = "overridden!" }
    
    Which can then be used from a custom strategy:
    
        class CustomStrategy
          def association(runner); end
    
          def result(evaluation)
            evaluation.object.tap do |instance|
              evaluation.notify(:custom_callback, instance)
            end
          end
        end
    
        FactoryGirl.register_strategy(:custom, CustomStrategy)
    
    This would allow for calling:
    
        FactoryGirl.custom(:user)
    
    Which would return the user instance but execute the :custom_callback callback
    on the user instance first.
    Josh Clayton and Jason Draper committed with joshuaclayton May 4, 2012
  2. Support *_list for all (including custom) strategies

    Josh Clayton and Joel Oliveira committed with joshuaclayton May 4, 2012
  3. Move strategy calculation to Factory#run

    Josh Clayton and Jason Draper committed with joshuaclayton May 4, 2012