<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I think the general consensus is that if you need this feature, then you have ugly code that needs cleaning up :) &nbsp;If you're in a situation like me, where you're too noob to figure out a better solution for some legacy code that you inherited, go to this url and find the instructions for installing Mocha:</div><div><br></div><div><a href="http://wiki.rubyonrails.org/rails/pages/Testing+Plugins">http://wiki.rubyonrails.org/rails/pages/Testing+Plugins</a></div><div><br></div><div>With it you can do:</div><div>ModelName.any_instance.stubs(:the_method).returns(happy_times)</div><div><br></div><div>However, I strongly encourage you to stare at your current code for a while and try to find a cleaner MVC-supportive solution. &nbsp;The general rule of thumb is that if it's difficult to write a spec for, then your code is ugly :) &nbsp;Hopefully in this case you can take this as an opportunity to improve your code. &nbsp;If not, Mocha works fairly well!</div><div><br></div><div>Glenn</div><br><div><html>On Apr 1, 2008, at 3:50 AM, Ashley Moran wrote:</html><br class="Apple-interchange-newline"><blockquote type="cite">On 01/04/2008, <b class="gmail_sendername">Jed Hurt</b> &lt;<a href="mailto:jed.hurt@gmail.com">jed.hurt@gmail.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Is there an easy way to stub an instance method for every new instance of a given class? I suppose I could just redefine the method, but I'm wondering if the RSpec mocking framework has this built in. </blockquote><div><br>Hi Jed<br><br>I hate it when other people ask this, but I can't help :)&nbsp; How come you need to do this?&nbsp; I've always wondered what the use case for this "mocking" strategy is<br><br> Ashley<br></div></div> _______________________________________________<br>rspec-users mailing list<br><a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br>http://rubyforge.org/mailman/listinfo/rspec-users</blockquote></div><br></body></html>