[rspec-users] Specing Rails Views

Chris Anderson jchris at mfdz.com
Sun Feb 11 17:47:03 EST 2007

On 2/11/07, Graeme Nelson <graeme.nelson at gmail.com> wrote:
> 2)  add a method in my setup to mock the :logged_in? call in the
> template, like so:
>         @controller.template.stub!(:logged_in?).and_return(true)

This looks like a fine way to do it, to me. Treating logged_in? as
just another attribute to be passed to the view (albeit in a slightly
specialized way, as it is a method called in the view) seems like the
right thing. This would make it easy to spec views in both the logged
in and logged out cases.

I still haven't gotten into specing views - as long as they don't
throw nasty errors, and they are valid xml, I let my designers handle
the work. But once we stablize the look and feel, I'll probably be
looking to add some regression type verification on the views.

Chris Anderson

More information about the rspec-users mailing list