Forum: RSpec 'Missing template' when using send_data to render response

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
38a91d5029a6e2a12ec7a083234bd7db?d=identicon&s=25 Chris Mear (Guest)
on 2009-03-16 14:27
(Received via mailing list)
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 Mear
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-03-16 14:31
(Received via mailing list)
2009/3/16 Chris Mear <chrismear@gmail.com>:
> 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?
38a91d5029a6e2a12ec7a083234bd7db?d=identicon&s=25 Chris Mear (Guest)
on 2009-03-16 15:28
(Received via mailing list)
On 16 Mar 2009, at 13:28, David Chelimsky 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
A3406e66dc2a5e80bbc2fd7d5342cc22?d=identicon&s=25 Chris Mear (Guest)
on 2009-03-16 15:40
(Received via mailing list)
2009/3/16 David Chelimsky <dchelimsky@gmail.com>

> > 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
This topic is locked and can not be replied to.