[rspec-users] [Rails] specifying that a layout yields?

Brandt Kurowski 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

  # http://gist.github.com/87246
  describe "/layouts/application" do
    it "should show the content" do
      class << template
        attr_accessor :did_render_content
      template.did_render_content = false
      render :inline => "<% self.did_render_content = true
%>", :layout => 'application'
      template.did_render_content.should be_true

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

Any ideas?



More information about the rspec-users mailing list