[rspec-users] Stubbing class in controller

Jamie D jam5t3r.lists at gmail.com
Sat Apr 19 17:04:45 EDT 2008


Thanks Ivo,

I was getting a bit confused with the stubs, thanks for the explanation.

Jamie

On 19/04/2008, Ivo Dancet <ivo.dancet at gmail.com> wrote:
> Hi
>
>  The 'loadavg' method is an instance method of 'whm', so the test
>  should be:
>
>  @whm = mock_model(Whm::Client)
>  Whm::Client.stub!(:new).and_return(@whm) # make the new method to
>  return a mock object
>  @whm.stub!(:loadavg).and_return(3) # 3 is the dummy loadavg, maybe you
>  can change it in something more meaningfull
>
>  For now, there is no real reason to put this into the test itself. I
>  think I would put this code in the before part.
>
>  Regards
>  Ivo


More information about the rspec-users mailing list