Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created June 19, 2017 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metaskills/d563c4012121ca100a7c109af097e722 to your computer and use it in GitHub Desktop.
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 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