How to test google analytics (garb) API with Rspec?

倖福魔咒の 提交于 2019-12-06 05:03:25

Fakeweb is a good place to start. It can isolate your SUT from the network so that slow connections don't affect your tests.

It's hard to know what else to say without knowing more about Garb. Obviously you'll need to know the format of the data to be sent and received from the API, so you can make the appropriate mocks/stubs.

I would suggest creating a testing interface that mimicks the actual calls to the google API. The other option would be to use mocks to create sample data.

I agree that it's best to not hit the actual API, since this does not gain you anything. A call to the actual API might succeed one day and fail the next because the API owners change the response format. Since GA probably won't change it's versioned API I think it's safe to create an interface that you can use in your test environments for faster testing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!