a_card = Card.new(:name => "Joe Winston")
a_phone = mock()
a_card.expects(:home_phone).returns(a_phone)
So I don't know what you're trying to test, but simply testing
ActiveRecord is generally considered bad form.
If you want to test that the association just accepts and returns a
phone number, go ahead and use a real phone number object instead of a
mock.
> --
> You received this message because you are subscribed to the Google Groups
> "mocha-developer" group.
> To post to this group, send email to mocha-d...@googlegroups.com.
> To unsubscribe from this group, send email to
> mocha-develop...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mocha-developer?hl=en.
>
>
--
Sent from my mobile device
Thanks... I wasn't testing ActiveRecord, as much as wanting to prove
that I had properly configured all my associations. I have a pretty
complicated set of associations. The case I reported in my question
was kind of reducing the problem to it's minimum to make it clear.
So: are you saying that it's not possible or hard to create a mock
with mocha which an active record associations would accept in an
assignment, i.e.
model parent has_many :children records
c = mock object stands in for a 'child record'
m = instance of 'parent'
m.children << c
Requires that when << sees 'c' it allows it to be added to the
'children' association. What can I do to mock 'c' so that the <<
works?
Impossible? (I know, I can create a 'real' Child and it will work)
Thanks!
Pito