Hey folks. In my controller specs, when I stub #render_to_string, #render is also stubbed out. Thus, if a controller action calls #render, the stubbed #render returns what #render_to_string returns, which causes specs to fail. http://pastie.org/2339809 Am I doing something strange or wrong? If not, how can I stub #render_to_string without affecting #render ? Thanks, Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110808/4b7162d1/attachment-0001.html>
David Chelimsky
2011-Aug-16 12:02 UTC
[rspec-users] Stubbing #render_to_string overrides #render
On Aug 8, 2011, at 10:36 AM, Nick wrote:> Hey folks. In my controller specs, when I stub #render_to_string, #render is also stubbed out.There is nothing in RSpec that binds these two methods together.> Thus, if a controller action calls #render, the stubbed #render returns what #render_to_string returns, which causes specs to fail. > > http://pastie.org/2339809 > > Am I doing something strange or wrong? If not, how can I stub #render_to_string without affecting #render ?IIRC, render(:json) eventually goes through render_to_string, which would explain the behavior you''re seeing. I could be wrong, but have a look at the Rails code as a starting point. Cheers, David
On Tuesday, August 16, 2011 8:02:08 AM UTC-4, dchel... at gmail.com wrote:> > IIRC, render(:json) eventually goes through render_to_string, which would > explain the behavior you''re seeing. I could be wrong, but have a look at the > Rails code as a starting point.Thanks, David. I''ll trace through Rails'' #render to see what''s going on. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110816/1f07d1cc/attachment.html>