[rspec-users] Mocking Models in Controller Specs...
svenfuchs at artweb-design.de
Thu May 29 14:30:52 EDT 2008
All the mentioned solutions are great, but for me they implied a bit
too much hassle to set up and also, given a larger number of specs, a
This discussion actually motivated me to publish my own stubbing
solution that I've recently implemented on GitHub. (This actually is a
kind of a factory plus a dsl to define your stubs).
Like said in the readme, the code is pretty new and bugs/problems
might well be present. Please let me know if you find any.
On 27.05.2008, at 11:37, Jarkko Laine wrote:
> 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.
>> ~ Mark
>> Posted via http://www.ruby-forum.com/.
>> rspec-users mailing list
>> rspec-users at rubyforge.org
> Jarkko Laine
> rspec-users mailing list
> rspec-users at rubyforge.org
sven fuchs svenfuchs at artweb-design.de
artweb design http://www.artweb-design.de
grünberger 65 + 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile)
More information about the rspec-users