Fabricator to return an instance of a different class

15 views
Skip to first unread message

Ilia Lobsanov

unread,
Jul 17, 2013, 12:23:42 PM7/17/13
to fabrica...@googlegroups.com
Is it possible for a Fabricator to return an instance of a different class?
I have two AR models: InactivePlace and Place. InactivePlace is copied to Place via InactivePlace#activate!
I want to have a place fabricator that 
- creates an instance of InactivePlace
- activates that instance 
- returns the Place instance corresponding to InactivePlace instance that was just activated

Paul Elliott

unread,
Jul 18, 2013, 1:53:22 PM7/18/13
to fabrica...@googlegroups.com
Hey Ilia,

I don't think that is going to be possible within fabrication. What you could do is put a method in `spec/support` that creates the object and calls `activate!` so that it is all wrapped up in one place. Then it would be available throughout your test suite and you could pass the arguments and block through to fabrication.

-- Paul

--
You received this message because you are subscribed to the Google Groups "fabrication" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabricationge...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages