avoid running AR callback / unstub method

35 views
Skip to first unread message

Nicolas Papon

unread,
Nov 21, 2011, 6:19:19 AM11/21/11
to factory_girl
Hello ,

I have some Rails Active Record models with "on create" callbacks. I'd
like to avoid them for some specific factories / traits . I was
thinking doing so :

factory :stuff_without_cb do
after_build do |item|
item.stub(:method_name)
end
after_create do |item|
item.unstub(:method_name)
end
end

The problem is that if there a stub method in factory girl from within
factory girl, i haven't found any "unstub" one , does anybody know a
work-around ?

Thanks in advance,

PS: i'm using Rspec , which doesn't seem to be loaded when my
factories are parsed (i'm using the last factory_girl_rails gem)

nicolas

Reply all
Reply to author
Forward
0 new messages