Sha256: 9b3877378b53c951d1aef7bdb0fcdd5caa84084d9314bcc9ae7748ca4a95da2e

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

require "rack"
require "webmock"

require "pipekit/webmock/request_signature_snippet"

module Pipekit
  module WebMock
    class UnregisteredPipedriveRequestError < StandardError
      WebMockNetConnectNotAllowedError = ::WebMock::NetConnectNotAllowedError unless const_defined?(:WebMockNetConnectNotAllowedError)

      def self.new(*args)
        request_signature = args[0]
        request_signature_snippet = RequestSignatureSnippet.new(request_signature)

        return WebMockNetConnectNotAllowedError.new(request_signature) unless request_signature_snippet.pipedrive_request?
        super(request_signature)
      end

      def initialize(request_signature)
        request_signature_snippet = RequestSignatureSnippet.new(request_signature)

        text = [
          "Unregistered request to Pipedrive: #{request_signature}",
          "with params:",
          request_signature_snippet.params,
          "and body:",
          request_signature_snippet.body,
          "="*60
        ].compact.join("\n\n")

        super(text)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pipekit-webmock-0.4.5 lib/pipekit/webmock/errors.rb
pipekit-webmock-0.4.4 lib/pipekit/webmock/errors.rb
pipekit-webmock-0.4.3 lib/pipekit/webmock/errors.rb
pipekit-webmock-0.4.2 lib/pipekit/webmock/errors.rb
pipekit-webmock-0.4.1 lib/pipekit/webmock/errors.rb
pipekit-webmock-0.4.0 lib/pipekit/webmock/errors.rb