[rspec-users] Mocking / stubbing errors for ActiveRecord

Zach Dennis zach.dennis at gmail.com
Thu Feb 19 17:11:17 EST 2009


On Thu, Feb 19, 2009 at 4:51 PM, Zach Dennis <zach.dennis at gmail.com> wrote:
> On Thu, Feb 19, 2009 at 3:54 PM, Martin <html-kurs at gmx.de> wrote:
>> Hi,
>>
>> I'm trying to test my views using rspec. I want to test my edit- and
>> new-view also for the case an error occurs (something like "title can't be
>> blank" and so on).
>> Can someone point me please to an example where I can see how to mock my
>>  model and stub all methods needed for the view?
>
> Here's two ways to approach writing examples against ensuring errors show up:
>
>   http://gist.github.com/67135
>

This gist is to show you how-to verify errors are displayed in a view,
not necessarily that you should go stubbing a bunch of superfluous
errors that may exist in the model to ensure they all show up. You
should only need to know that the errors are being displayed and one
dummy error message does that.

> Note, that if your model really exists, you can use stub_model instead
> of mock_model.
>
>
>
>
>>
>> Thank you,
>> Martin
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
>
>
>
> --
> Zach Dennis
> http://www.continuousthinking.com
> http://www.mutuallyhuman.com
>



-- 
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com


More information about the rspec-users mailing list