File: excon.rb

package info (click to toggle)
ruby-vcr 6.0.0%2Breally5.0.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,320 kB
  • sloc: ruby: 8,456; sh: 177; makefile: 7
file content (35 lines) | stat: -rw-r--r-- 939 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'vcr/middleware/excon'

module VCR
  class LibraryHooks
    module Excon
      # @private
      def self.configure_middleware
        middlewares = ::Excon.defaults[:middlewares]

        middlewares << VCR::Middleware::Excon::Request
        response_parser_index = middlewares.index(::Excon::Middleware::ResponseParser)
        middlewares.insert(response_parser_index + 1, VCR::Middleware::Excon::Response)
      end

      configure_middleware
    end
  end
end

VCR.configuration.after_library_hooks_loaded do
  # ensure WebMock's Excon adapter does not conflict with us here
  # (i.e. to double record requests or whatever).
  if defined?(WebMock::HttpLibAdapters::ExconAdapter)
    WebMock::HttpLibAdapters::ExconAdapter.disable!

    if defined?(::RSpec)
      ::RSpec.configure do |config|
        config.before(:suite) do
          WebMock::HttpLibAdapters::ExconAdapter.disable!
        end
      end
    end
  end
end