|
24 | 24 | c.non_successful_error_level = :warn
|
25 | 25 |
|
26 | 26 | # cache_path is where responses from external URLs will be saved as YAML.
|
27 |
| - c.cache_path = "spec/support/http_cache/frontend/" |
| 27 | + c.cache_path = "spec/support/http_cache/frontend/" |
28 | 28 |
|
29 | 29 | # Avoid having tests dependent on external URLs.
|
30 | 30 | #
|
31 | 31 | # Only set non_whitelisted_requests_disabled **temporarily**
|
32 | 32 | # to false when first recording a 3rd party interaction. After
|
33 | 33 | # the recording has been stored to cache_path, then set
|
34 | 34 | # non_whitelisted_requests_disabled back to true.
|
35 |
| - c.non_whitelisted_requests_disabled = true |
| 35 | + c.non_whitelisted_requests_disabled = false |
| 36 | +end |
| 37 | + |
| 38 | +# https://github.com/oesmith/puffing-billy#working-with-vcr-and-webmock |
| 39 | +if defined?(VCR) |
| 40 | + VCR.configure do |config| |
| 41 | + config.ignore_request { |request| handled_by_billy?(request) } |
| 42 | + end |
| 43 | + |
| 44 | + def handled_by_billy?(request) |
| 45 | + # browser_referer?(request) |
| 46 | + browser_user_agent?(request) |
| 47 | + end |
| 48 | + |
| 49 | + def browser_user_agent?(request) |
| 50 | + user_agent = !request.headers["User-Agent"].blank? && request.headers["User-Agent"].first |
| 51 | + is_real_browser_user_agent = user_agent != "Ruby" |
| 52 | + end |
| 53 | + |
| 54 | + # def allowed_referers |
| 55 | + # [ |
| 56 | + # %r{\Ahttp://#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}/}, |
| 57 | + # %r{\Ahttps://checkout\.stripe\.com}, |
| 58 | + # %r{\Ahttps://b\.stripecdn\.com} |
| 59 | + # ] |
| 60 | + # end |
| 61 | + |
| 62 | + # def browser_referer?(request) |
| 63 | + # referer = !request.headers["Referer"].blank? && request.headers["Referer"].first |
| 64 | + # handled = referer && allowed_referers.any? { |pattern| pattern =~ referer } |
| 65 | + # end |
36 | 66 | end
|
37 | 67 |
|
38 | 68 | # 5. Uncomment the *_billy driver for your desired browser:
|
|
0 commit comments