I'm loving ActionView::TestCase and it's time to give back a bit...
ActionView::TestCase creates a view with a nil output buffer -probably
assuming that all rendering simply returns a string. However,
rendering a layout does not return a string -instead
#_render_with_layout concatenates the result of rendering the layout
as a partial onto the view's output buffer. Because the view's output
buffer is nil, an exception is raised for invoking append (<<) on nil.
Which component is breaking the rules? Is is the TestCase, which
neglects to provide an output buffer for the view? Or is it
ActionView::Base#render_with_layout that doesn't follow convention and
simply return a string? Fixing TestCase is easy. Fixing
render_with_layout will be (much) harder.
A simple work-around is to provide the view with an output buffer.
Arguably, this is the Right Thing To Do (TM) regardless. It would
appear that without it testing concat in a rendering helper is broken.
This behavior is observed in 2-3-stable. I think AV::TC has been
rewritten for 3.0/master so I can't comment on those branches.
Other (indirect) references to this problem:
To be pragmatic, I've created a one-line patch that links the test
case's output buffer to the view's output buffer.
It applies cleanly to 2-3-stable.
It includes a failing test.
All action pack tests pass with the patch.
Looking for testers...