Skip to content

Instantly share code, notes, and snippets.

@tinney
Created March 13, 2015 15:08
Show Gist options
  • Save tinney/91762fec87ee5db5d648 to your computer and use it in GitHub Desktop.
Save tinney/91762fec87ee5db5d648 to your computer and use it in GitHub Desktop.
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
require 'vcr'
require 'webmock'
VCR.configure do |c|
c.cassette_library_dir = './tmp/vcr-cassettes/'
c.hook_into :webmock
end
WebMock.allow_net_connect! net_http_on_start: false
use VCR::Middleware::Rack do |cassette, env|
vin_pattern = /[a-z0-9&&[^ioq]]{17}/i
cassette_name = "external-request"
if body = env["rack.input"]
begin
if vin = body.read[vin_pattern]
WebMock.disable_net_connect!(allow: => ["chrome"])
cassette_name = "chromedata-request-#{vin}"
end
ensure
body.rewind
end
end
cassette.name cassette_name
cassette.options { record: :new_episodes,
match_requests_on: [:uri, :body] }
end
run Autoguard::Application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment