Sha256: 778813490d844a7cbcf426f4e8aa2610ad96c20349f6217aa976d90dc153676a
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
require "rack" require "webmock" module Pipekit module WebMock class UnregisteredPipedriveRequestError < StandardError WebMockNetConnectNotAllowedError = ::WebMock::NetConnectNotAllowedError unless const_defined?(:WebMockNetConnectNotAllowedError) def initialize(request_signature) return WebMockNetConnectNotAllowedError.new(request_signature) unless request_signature.uri.hostname == "api.pipedrive.com" resource = request_signature.uri.path.split("/").last[0..-2] query = request_signature.uri.query body = request_signature.body text = [ "Unregistered request to Pipedrive: #{request_signature.uri}", "with params:", extract_params(resource, query), "and body:", extract_params(resource, body), "="*60 ].compact.join("\n\n") super(text) end def extract_params(resource, query) params = Rack::Utils.parse_nested_query(query) params.reduce({}) do |result, (field, value)| field = Config.field_name(resource, field) value = Config.field_value(resource, field, value) result.tap { |result| result[field] = value } end.map { |k, v| "#{k}: #{v}" }.join("\n") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pipekit-webmock-0.1.0 | lib/pipekit/webmock/errors.rb |