Created
June 19, 2017 16:41
-
-
Save metaskills/d563c4012121ca100a7c109af097e722 to your computer and use it in GitHub Desktop.
Per-Service VCR Cassettes - Reuse Common API Requests Across Your App's Tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This assumes you have a client with a URL config. Hard coded URLs work too. | |
# Will automiatically insert cassets whenever needed and organize them per servcie. | |
# | |
VCR.configure do |c| | |
c.around_http_request do |request| | |
if request.uri =~ Regexp.new(MyServiceClient.config.url) | |
VCR.use_cassette 'my_service', default_cassette_options, &request | |
else | |
request.proceed | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment