How to assert a specific layout.

Hi.

Can any test-guru help me on this one.

How do I (in my functional test) that a specific controller/action uses a certain layout?

I would like to see something similar to assert_template (for asserting a specific view), but for layouts.

How do you guys test use of a specific layout?

Jarl

This seems to work **http://bjhess.com/blog/2008/04/27/five-rails-tips/**found by google for assert_layout

Colin

Colin Law wrote:

This seems to work *http://bjhess.com/blog/2008/04/27/five-rails-tips/

*found by google for assert_layout

I like this section:

The flexibility of assert_select:

Did you know you can use regular expressions with assert_select? It’s pretty fun. Here’s a selector to verify a page does not include any table rows with ids of the form “day_entry_#”. assert_select "tr[id*=?]", /day_entry_\d+/, :count => 0

It's the same as...

   assert_xhtml{ without!{ tr :id => /day_entry_\d+/ } }

I would really be interested to learn of an assert_select which assert_xhtml cannot do...

Interested to see my blog post name-dropped here.

Philip, I assume you're the original assert{ 2.0 } Philip, yes?

I actually had thought that project was in stasis. I'm the only person I know using assert{ 2.0 }, but I do love it. The assert{ } syntax along with the useful failure output is a big win.

Looks like you're adding on to that puppy - cool. Sadly, I haven't written an assert_select for a long while, so assert_xhtml isn't solving any pain points at this time. But I'll still happily go on using assert{ 2.0 } as is!

bjhess wrote:

Interested to see my blog post name-dropped here.

Philip, I assume you're the original assert{ 2.0 } Philip, yes?

O'Reilly Media - Technology and Business Training

I actually had thought that project was in stasis. I'm the only person I know using assert{ 2.0 }, but I do love it. The assert{ } syntax along with the useful failure output is a big win.

The version for Ruby 1.9 has a better layout at fault time. (I can factually identify the freaking \n linefeeds in the {} block using Ripper! Woot!)

Looks like you're adding on to that puppy - cool. Sadly, I haven't written an assert_select for a long while, so assert_xhtml isn't solving any pain points at this time. But I'll still happily go on using assert{ 2.0 } as is!

Np. Another goal is its sub-modules take care of themselves, and you don't need to worry about them if you don't use them. xhtml.rb is not big enough for its own product, and after the 1.9 transition I will be free to unify all the diagnostic techniques into a seamless whole.

Folks, the point of the assert{ 2.0 } project is to make a lowly assertion as powerful as CppUnit ASSERT() was for me in Visual Studio (back in the days when MS still had a shred of relevance). When an assertion failed, it invoked a debugger breakpoint, and you would see in one window...

  - the test source   - the call stack   - sometimes the code source   - all your local variable's values.

There's no reason any assert should not give you all that. You should not have to write extra at test time to get it - that would just slow you down!

Jarl Friis <jarl@gavia.dk> writes:

Hi.

Can any test-guru help me on this one.

Certainly there was.

Thanks for all the answers, also all the posts regarding alternatives.

I will have a look at all this.

Jarl