[rspec-users] [Rails] specifying that a layout yields?
brandtkurowski at gmail.com
Sat Mar 28 21:33:50 EDT 2009
I recently had a bug in a layout due to the layout not calling "yield"
to display the actual content. I wanted to write a spec to describe
what was missing, but it wasn't obvious how, so I just fixed the
problem first and doubled back to spec it later.
Anyway, the most succinct thing I was able to come up with was the
describe "/layouts/application" do
it "should show the content" do
class << template
template.did_render_content = false
render :inline => "<% self.did_render_content = true
%>", :layout => 'application'
But I'm not quite satisfied with this, as it's not as clear and
expressive as specs usually are. I thought I'd write a custom matcher
for it, but it's not obvious to me what I'd even want the spec to look
More information about the rspec-users