[rspec-users] Mocking Models in Controller Specs...

Jarkko Laine
Tue, 27 May 2008 09:37:17 -0000

On 27.5.2008, at 10.52, Mark Dodwell wrote:

> Also, any opinions on using a Factory pattern for instantiating
> mocks of
> models? I like the idea of maintaining mocks in one place as I
> frequently use them across several specs for models that have
> associations. Do you think it would create dependency issues between
> the
> specs using that Factory?

I have built my own "factory" by creating methods such as mock_user in
the spec helper. That method will then fill in some reasonable values
and stub all the needed methods. Granted, the need for that is less
now with stub_model, but sometimes you also want to stub some
associations. That has certainly reduced the amount of repetition in
my specs.

//jarkko

>
>
> ~ Mark
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2417 bytes
Desc: not available
URL:
<http://rubyforge.org/pipermail/rspec-users/attachments/20080527/3ef9aaee/attachment.bin>