Sha256: 9a2781db2f87d7f21a5097437cc38b81f155cf08d1948ee41f55dd4cb69c1be2
Contents?: true
Size: 1.96 KB
Versions: 2
Compression:
Stored size: 1.96 KB
Contents
require 'faraday' module VCR module HttpStubbingAdapters module Faraday include Common extend self MINIMUM_VERSION = '0.5.3' MAXIMUM_VERSION = '0.5' attr_writer :http_connections_allowed def http_connections_allowed? !!@http_connections_allowed end def ignored_hosts=(hosts) @ignored_hosts = hosts end def uri_should_be_ignored?(uri) uri = URI.parse(uri) unless uri.respond_to?(:host) ignored_hosts.include?(uri.host) end def stub_requests(http_interactions, match_attributes) grouped_responses(http_interactions, match_attributes).each do |request_matcher, responses| queue = stub_queues[request_matcher] responses.each { |res| queue << res } end end def create_stubs_checkpoint(cassette) checkpoints[cassette] = stub_queue_dup end def restore_stubs_checkpoint(cassette) @stub_queues = checkpoints.delete(cassette) || super end def stubbed_response_for(request_matcher) queue = stub_queues[request_matcher] return queue.shift if queue.size > 1 queue.first end def reset! instance_variables.each do |ivar| remove_instance_variable(ivar) end end private def version ::Faraday::VERSION end def ignored_hosts @ignored_hosts ||= [] end def checkpoints @checkpoints ||= {} end def stub_queues @stub_queues ||= hash_of_arrays end def stub_queue_dup dup = hash_of_arrays stub_queues.each do |k, v| dup[k] = v.dup end dup end def hash_of_arrays Hash.new { |h, k| h[k] = [] } end end end end VCR::HttpStubbingAdapters::Common.add_vcr_info_to_exception_message(VCR::Middleware::Faraday::HttpConnectionNotAllowedError)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vcr-1.7.0 | lib/vcr/http_stubbing_adapters/faraday.rb |
vcr-1.6.0 | lib/vcr/http_stubbing_adapters/faraday.rb |