thoughtbot/factory_girl — Issue #237: Using callbacks within decorate
Author: apneadiving
Created: 2011-11-14 21:55:27+00:00
State: open

Hi,

First and foremost, FactoryGirl is simply as great as useful.

I just stumbled on this (basically a callback within `decorate`):

trait :admin do
groups [:admins]
end

factory :user do
sequence(:email) {|n| "factory_#{n}@example.com" }
password "password"
password_confirmation "password"
activities ["none"]

decorate :active do
after_create {|u| a.author_profile.status = :active; a.author_profile.save }
end

factory :admin, :traits => [:admin ]
end

And here are the relevant line of the stacktrace:

in `add_attribute': Both value and block given (FactoryGirl::AttributeDefinitionError)
.../factory_girl/definition_proxy.rb:89:in `method_missing'

Am I missing something?