dc10
dc10

Reputation: 2208

How to to test responses from a 3rd party api in rails 3

I am making heavy use of 3rd party API's (google contacts,etc) in my application. I am pretty new to testing in rails, but ever since I find it very difficult to test my models which rely on the response on an api. My ultimate goal is to test valid return values from my models, therefore they get initialized with values from the api. So I was wondering how can I test this. Of course it would be possible to call the api and just pass the values, but this would take plenty of time. Is there maybe a nice way of mocking api responses?

Best, Phil

Upvotes: 0

Views: 439

Answers (1)

hyperrjas
hyperrjas

Reputation: 10744

you can use this gem:

https://github.com/vcr/vcr

You have various resources to learn how it works:

https://github.com/vcr/vcr

http://railscasts.com/episodes/291-testing-with-vcr

Regards!

Upvotes: 2

Related Questions