views:

64

answers:

2

Hi,

I'm trying to stub a third party service that my metal talks to. It seems rspec mocks/stubs don't extend all the way to the Metal.

When I call stubbed methods on objects, it calls the original one and not the stubbed one.

Any idea of how I can have rSpec doubles extend all the way to the metal?

Thanks.

-Nash

A: 

Have you considered using Fakeweb instead? This allows you to block all outgoing traffic and send a custom response instead. This way you don't even have to write a mock. It's very lightweight and easy to use.

ajmurmann
I've used Fakeweb before. It's really cool, but maybe overkill to use just for this instance.It turns out my problem was in the step definition I was using HTTParty to post to the metal, which was using the environment defined in passenger (development) and not the test environment.The fix was to use webrat visit(url, :post, data) to have execute in test mode.Thanks for the suggestion.
Nash
Nash - can you mark this as complete if you solved it?
Jesse Wolgamott
A: 

You can also try using WebMock http://github.com/bblimke/webmock

Bartosz Blimke