I do mock errors sometimes or I just call the server with invalid data and register the possible error messages.
Some APIs have different error messages for different cases and for me it's faster to record them than to actually figure out how to mock all of them.
My issue with API mocks is that they can be difficult to maintain updated, it's not this case because S3 is not going to change at all but for APIs where there's no client, just the documentation, I am way faster if I record it once instead of using mocks.
To be able to mock those, you still need to wire up Postman, hit them once, check the response, mock such response, so why not do that using VCR?
I heard about exvcr, it's another approach - can work but technically, I don't want to hit the server and ‘replay’ it back during tests.
From the awesome thoughtbot post, there're considerations when using VCR:
I also realized the mocking module looks very simple, I should handle multiple response statuses.
I do mock errors sometimes or I just call the server with invalid data and register the possible error messages.
Some APIs have different error messages for different cases and for me it's faster to record them than to actually figure out how to mock all of them.
My issue with API mocks is that they can be difficult to maintain updated, it's not this case because S3 is not going to change at all but for APIs where there's no client, just the documentation, I am way faster if I record it once instead of using mocks.
To be able to mock those, you still need to wire up Postman, hit them once, check the response, mock such response, so why not do that using VCR?
I understand and agree with you. But I don't want to use VCR because there are many ways to do the external testing. VCR is just an approach.
About the reason: after reading the thoughtbot post and personally I want to keep my code is simple. That's all.
Btw I can use Postman to get the response from external services and update for my mock modules.
that is absolutely true :-)
Thanks for the discussion!
I've found the Bypass lib to be very useful: github.com/PSPDFKit-labs/bypass
Here are a couple resources I used to get started with it: