Re: [rspec-users] Stub an instance method for every new instance of a class

2008-04-02 Thread Jed Hurt
Ahhh, clever. I see the light On Wed, Apr 2, 2008 at 8:19 AM, Corey Haines <[EMAIL PROTECTED]> wrote: > Create an instance of the controller > > contr = MyController.new > > MyController.stub!(:new).and_return contr > > contr.stub!(:method_i_want_to_stub).and_return 'sweetness' > > Something like

Re: [rspec-users] Stub an instance method for every new instance of a class

2008-04-02 Thread Corey Haines
Create an instance of the controller contr = MyController.new MyController.stub!(:new).and_return contr contr.stub!(:method_i_want_to_stub).and_return 'sweetness' Something like this? -Corey On Wed, Apr 2, 2008 at 12:22 AM, Jed Hurt <[EMAIL PROTECTED]> wrote: > I'm not sure how that would wo

Re: [rspec-users] Stub an instance method for every new instance of a class

2008-04-01 Thread Jed Hurt
I'm not sure how that would work. For controller specs, I want to keep most of the controller intact so that I can verify its actual behavior. Am I missing something? On Tue, Apr 1, 2008 at 12:12 PM, David Chelimsky <[EMAIL PROTECTED]> wrote: > On Tue, Apr 1, 2008 at 2:11 PM, Corey Haines <[EMAIL

Re: [rspec-users] Stub an instance method for every new instance of a class

2008-04-01 Thread David Chelimsky
On Tue, Apr 1, 2008 at 2:11 PM, Corey Haines <[EMAIL PROTECTED]> wrote: > Could you stub out Controller.new and return your mock? Bingo. > > > > On Tue, Apr 1, 2008 at 1:19 PM, Jed Hurt <[EMAIL PROTECTED]> wrote: > > Haha, that's about the response I was expecting; I asked with some > trepidation

Re: [rspec-users] Stub an instance method for every new instance of a class

2008-04-01 Thread Corey Haines
Could you stub out Controller.new and return your mock? On Tue, Apr 1, 2008 at 1:19 PM, Jed Hurt <[EMAIL PROTECTED]> wrote: > Haha, that's about the response I was expecting; I asked with some > trepidation. I'm just looking for a quick hack to short-circuit Merb's > render method to do some view

Re: [rspec-users] Stub an instance method for every new instance of a class

2008-04-01 Thread Jed Hurt
Haha, that's about the response I was expecting; I asked with some trepidation. I'm just looking for a quick hack to short-circuit Merb's render method to do some view/controller isolation testing until Merb officially supports it. I can't just stub methods on @controller (like in Rails) because th

Re: [rspec-users] Stub an instance method for every new instance of a class

2008-04-01 Thread Glenn Ford
I think the general consensus is that if you need this feature, then you have ugly code that needs cleaning up :) 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 in

Re: [rspec-users] Stub an instance method for every new instance of a class

2008-04-01 Thread Ashley Moran
On 01/04/2008, Jed Hurt <[EMAIL PROTECTED]> wrote: > > 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. Hi Jed I hate it when other people a

[rspec-users] Stub an instance method for every new instance of a class

2008-03-31 Thread Jed Hurt
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. ___ rspec-users mailing list rspec-users@rubyforge.org