Skip to content

Commit e369df1

Browse files
committed
Configure VCR and Webmock
Disable most external requests with WebMock Use VCR only with RSpec :vcr metadata
1 parent 38a5550 commit e369df1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

spec/support/webmock_vcr.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require "webmock/rspec"
2+
require "vcr"
3+
4+
VCR.configure do |config|
5+
config.cassette_library_dir = "spec/cassettes"
6+
config.hook_into :webmock
7+
config.ignore_localhost = true
8+
config.configure_rspec_metadata!
9+
end
10+
11+
RSpec.configure do |config|
12+
config.before(:each) do
13+
WebMock.disable_net_connect!(
14+
allow_localhost: true,
15+
allow: [
16+
"chromedriver.storage.googleapis.com",
17+
"validator.w3.org"
18+
]
19+
)
20+
end
21+
22+
config.around do |example|
23+
if example.metadata.key?(:vcr)
24+
example.run
25+
else
26+
VCR.turned_off { example.run }
27+
end
28+
end
29+
end

0 commit comments

Comments
 (0)