I'd be happy to submit a PR that implements VCR-like support as implemented here:
https://github.com/mwlang/binance/blob/master/spec/support/vcr.cr
Basic idea taken from the Ruby VCR gem
With this, it makes writing a spec like this possible:
context "success response" do
it "#ping" do
with_vcr_cassette "public/ping_success" do
client.ping.pong.should be_truthy
end
end
end
context "error response" do
it "#ping" do
with_vcr_cassette("public/ping_error") do
response = client.ping
response.body.should eq "{\"code\": -3121, \"msg\": \"Strange Error.\"}"
response.error_code.should eq -3121
response.success.should be_falsey
end
end
end
The first time a cassette is called and it's file does not exist, then the spec is implemented with a live call to the API server, capturing the response and writing both the request and response data to a *.yml file. The subsequent calls plays back the information captured.
Is there interest in adding this to the webmock shard? If so and approved, I'll implement in a PR and submit for consideration. If not interested, I will perhaps consider extracting this to a public shard, but would not have the time to take on a full-fledged re-implementation of the original Ruby vcr gem, hence the thought to contribute into the webmock framework where it's likely to be better maintained and grow with the community support.
I'd be happy to submit a PR that implements VCR-like support as implemented here:
https://github.com/mwlang/binance/blob/master/spec/support/vcr.cr
Basic idea taken from the Ruby VCR gem
With this, it makes writing a spec like this possible:
The first time a cassette is called and it's file does not exist, then the spec is implemented with a live call to the API server, capturing the response and writing both the request and response data to a *.yml file. The subsequent calls plays back the information captured.
Is there interest in adding this to the webmock shard? If so and approved, I'll implement in a PR and submit for consideration. If not interested, I will perhaps consider extracting this to a public shard, but would not have the time to take on a full-fledged re-implementation of the original Ruby vcr gem, hence the thought to contribute into the webmock framework where it's likely to be better maintained and grow with the community support.