[rspec-users] layout template

David Chelimsky dchelimsky at gmail.com
Tue May 29 18:19:17 EDT 2007


On 5/29/07, Jonathan Linowes <jonathan at parkerhill.com> wrote:
> to answer my own question here, @layout is a variable so
>
>     response.layout.should == 'layouts/pages'

This is a great case for a custom matcher, if you're interested. Something like:

   response.should use_layout('pages')

Check out http://blog.davidchelimsky.net/articles/2007/02/18/custom-expectation-matchers
for info on how-to.

>
>
>
> On May 29, 2007, at 11:57 AM, Jonathan Linowes wrote:
>
> > Hi,
> >
> > yes I realize I can assert the view template. I'm trying to assert
> > the layout one.
> >
> > I've tried
> > response.should render_template("pages")
> > and
> > response.should render_template("layouts/pages")
> > and
> > response.should render_template("/layouts/pages")
> > and
> > response.should render_template('/app/views/layouts/site_pages')
> >
> >
> > On May 29, 2007, at 8:36 AM, Anthony Carlos wrote:
> >
> >>
> >> On May 29, 2007, at 4:54 AM, Jonathan Linowes wrote:
> >>
> >>> Hi, rather than flooding this list with separate emails, I've been
> >>> queueing up questions using rspec with rails. (an irc channel would
> >>> be nice too :) Here ya go...
> >>>
> >>> - Can you assert which layout template is rendered in a controller
> >>> spec?
> >>>
> >>
> >> I'll answer this one:
> >>
> >> response.should render_template()
> >>
> >> Don't forget to include either a GET or POST, and if you're using
> >> stubs or mocks, watch test.log for errors. I've noticed that when I
> >> stub out a model object, for example, if I don't stub out all the
> >> methods that get called before the action gets to my render, then the
> >> spec fails but without a lot of related info. test.log will usually
> >> give me a hint with a stack trace.
> >>
> >> It's documented here: http://rspec.rubyforge.org/documentation/rails/
> >> writing/controllers.html
> >>
> >>>
> >>> That's it for now :) thanks
> >>> linoj
> >>>
> >>>
> >>> _______________________________________________
> >>> rspec-users mailing list
> >>> rspec-users at rubyforge.org
> >>> http://rubyforge.org/mailman/listinfo/rspec-users
> >>
> >> _______________________________________________
> >> rspec-users mailing list
> >> rspec-users at rubyforge.org
> >> http://rubyforge.org/mailman/listinfo/rspec-users
> >
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list