Chris Mear
2009-Mar-16 13:21 UTC
[rspec-users] ''Missing template'' when using send_data to render response
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090316/275666e3/attachment-0001.html>
David Chelimsky
2009-Mar-16 13:28 UTC
[rspec-users] ''Missing template'' when using send_data to render response
2009/3/16 Chris Mear <chrismear at gmail.com>:> 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?How about controller.stub!(:render) also? You want should_receive(:send_data) because that''s the spec, right?> Many thanks, > Chris Mear > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Chris Mear
2009-Mar-16 14:13 UTC
[rspec-users] ''Missing template'' when using send_data to render response
2009/3/16 David Chelimsky <dchelimsky at gmail.com>> 2009/3/16 Chris Mear <chrismear at gmail.com>: > > 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? > > 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090316/057944a7/attachment.html>
Chris Mear
2009-Mar-16 14:23 UTC
[rspec-users] ''Missing template'' when using send_data to render response
On 16 Mar 2009, at 13:28, David Chelimsky wrote:> 2009/3/16 Chris Mear <chrismear at gmail.com>: >> 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? > > 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