Skip to content

Commit

Permalink
Monkey patch vcr Ruby 3.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
hennevogel committed Mar 15, 2022
1 parent 57c864b commit 5579efe
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/api/spec/support/vcr.rb
Expand Up @@ -28,3 +28,35 @@
# You can also limit this to the type of test with
# config.before(:each, type: feature) do...
end

# FIXME: Remove when VCR 6.0.1 is released
# https://github.com/vcr/vcr/pull/907/files
# rubocop:disable Style/ModuleFunction
module VCR
class LibraryHooks
# @private
module WebMock
extend self

def with_global_hook_disabled(request)
global_hook_disabled_requests << request

begin
yield
ensure
global_hook_disabled_requests.delete(request)
end
end

def global_hook_disabled?(request)
requests = Thread.current[:_vcr_webmock_disabled_requests]
requests && requests.include?(request)
end

def global_hook_disabled_requests
Thread.current[:_vcr_webmock_disabled_requests] ||= []
end
end
end
end
# rubocop:enable Style/ModuleFunction

0 comments on commit 5579efe

Please sign in to comment.