> On Sep 21, 2018, at 8:03 AM, Daynthan Kabilan <dayanthan86@gmail.com> wrote:
>
> Hi,
>
> Anyone please give me some idea about how to write test case with API endpoints.
>
> I have used multiple API in my application. Currently i need to write the testcase to the API. So needs to be some request test specs (using rspec, preferrably) for all of the major ruby API endpoints.
>
> Thanks for advance
We use VCR to wrap around the API. https://github.com/vcr/vcr It's pretty straightforward. You put a VCR block around the part of your test that requests the external resource, and then you just make a normal request inside your test. The first time it runs, VCR will write out a "cassette" for that request, which is just a serialized version of the HTTP traffic response. The next time it runs, you will hit the cassette, not the network. Saves a bunch of time when you are done fiddling with the API tests and have moved on to other parts of your app. If you ever worry about your tests getting away from reality, you can just delete the cassettes and run the test again to refresh them with a newer version.
Walter
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADKeJyQfjN6WoE1GeBdVR%3DTqTGMS5uOxRYzKRF35eTzUAwdQfQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/10175416-F15A-4AFC-82E2-0E4E85A7605C%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment