# 'Missing template' when using send\_data to render response

**URL:** <https://www.ruby-forum.com/t/missing-template-when-using-send-data-to-render-response/163000>\
**Category:** RSpec\
**Created:** [March 16, 2009, 2:27pm UTC](https://www.ruby-forum.com/t/missing-template-when-using-send-data-to-render-response/163000 "2009-03-16T14:27:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [March 16, 2009, 2:27pm UTC](https://www.ruby-forum.com/t/missing-template-when-using-send-data-to-render-response/163000/1 "2009-03-16T14:27:03Z")

</div>

Hi there,  
Just upgraded to Rails 2.3/RSpec 1.2.0, and I’ve got a controller that  
uses  
send\_data to render a response. In the controller spec, I have:

controller.should\_receive(:send\_data).with(…)

The send\_data method calls ‘render’ internally, but obviously when I  
stub/mock out the send\_data method this doesn’t get called. So, with the  
changes to controller/template isolation in 1.2.0, I now get a ‘missing  
template’ error on this example as the controller tries to render the  
default template.

Any suggestions to the best way to resolve this? My hunch is that it’ll  
need  
an extension to RenderObserver in rspec-rails, but I’m struggling to do  
the  
right thing in my first foray into the RSpec source. Or maybe I  
shouldn’t be  
mocking the send\_data call at all, but rather then underlying render  
call?

Many thanks,  
Chris M.

---

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [March 16, 2009, 2:31pm UTC](https://www.ruby-forum.com/t/missing-template-when-using-send-data-to-render-response/163000/2 "2009-03-16T14:31:45Z")

</div>

2009/3/16 Chris M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> an extension to RenderObserver in rspec-rails, but I’m struggling to do the  
> right thing in my first foray into the RSpec source. Or maybe I shouldn’t be  
> mocking the send\_data call at all, but rather then underlying render call?

How about controller.stub!(:render) also? You want  
should\_receive(:send\_data) because that’s the spec, right?

---

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [March 16, 2009, 3:28pm UTC](https://www.ruby-forum.com/t/missing-template-when-using-send-data-to-render-response/163000/3 "2009-03-16T15:28:17Z")

</div>

On 16 Mar 2009, at 13:28, David C. wrote:

> > 'missing
> 
> How about controller.stub!(:render) also? You want  
> should\_receive(:send\_data) because that’s the spec, right?

Oh, of course! That works beautifully. Too much overthinking on my part.

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [March 16, 2009, 3:40pm UTC](https://www.ruby-forum.com/t/missing-template-when-using-send-data-to-render-response/163000/4 "2009-03-16T15:40:38Z")

</div>

2009/3/16 David C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> > default template.  
> > should\_receive(:send\_data) because that’s the spec, right?  
> > Oh, of course! That works beautifully. Too much overthinking on my part.

Cheers,  
Chris
