[rspec-users] Mocking Models in Controller Specs...
dchelimsky at gmail.com
Mon May 26 16:05:48 EDT 2008
On May 26, 2008, at 2:52 PM, Mark Dodwell wrote:
> I find myself doing this kind of thing a lot in Controller Specs:
> @vacancy = mock_model(Vacancy)
> I have to stub each of these methods so that the form renders
> (as I am using integrate_views). This just feels *way* too much code
> effort to do this. I have a spec for one controller (which just does
> plain old CRUD) that is over 300 LOC -- this seems a bit nuts to me
> the controller is only 50 LOC.
> Does anybody have any suggestions on how to avoid this or perhaps I am
> doing something wrong!?
Use stub_model instead (if you're using source from github - if not
the 1.4 release is coming soon).
> I make use of a Factory pattern to create instances for my model unit
> tests -- could I use a similar pattern for a 'mock factory'? Is
> doing anything similar?
> ~ Mark
> Posted via http://www.ruby-forum.com/.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users