Sha256: ae68143c6ad76a2aae7c051293d2d3877aed3563b2d376efa159c459a390b301

Contents?: true

Size: 954 Bytes

Versions: 3

Compression:

Stored size: 954 Bytes

Contents

require 'fake_web'

module FakeWeb
  def self.remove_from_registry(method, url)
    Registry.instance.remove(method, url)
  end

  def self.with_allow_net_connect_set_to(value)
    original_value = FakeWeb.allow_net_connect?
    begin
      FakeWeb.allow_net_connect = value
      yield
    ensure
      FakeWeb.allow_net_connect = original_value
    end
  end

  class Registry #:nodoc:
    def remove(method, url)
      uri_map.delete_if do |uri, method_hash|
        if normalize_uri(uri) == normalize_uri(url)
          method_hash.delete(method)
          method_hash.empty? # there's no point in keeping this entry in the uri map if its method hash is empty...
        end
      end
    end
  end

  class NetConnectNotAllowedError
    def message
      super + '.  You can use VCR to automatically record this request and replay it later with fakeweb.  For more details, see the VCR README at: http://github.com/myronmarston/vcr'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vcr-0.3.1 lib/vcr/extensions/fake_web.rb
vcr-0.3.0 lib/vcr/extensions/fake_web.rb
vcr-0.2.0 lib/vcr/extensions/fake_web.rb