[rspec-users] [Rails] specifying that a layout yields?
matt at mattwynne.net
Mon Mar 30 03:39:57 EDT 2009
On 29 Mar 2009, at 02:33, Brandt Kurowski wrote:
> 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?
That's some pretty nifty code Brandt :)
Did you consider testing this aspect of the view's behaviour from a
higher-level Cucumber acceptance test? I think that's what I would
have probably done.
More information about the rspec-users