Sha256: 63b8e071ff41bb6ea010063a4f775908003ba181faad4801f3f122229c9a3aee

Contents?: true

Size: 986 Bytes

Versions: 13

Compression:

Stored size: 986 Bytes

Contents

module WebMock

  class NetConnectNotAllowedError < Exception
    def initialize(request_signature)
      text = "Real HTTP connections are disabled. Unregistered request: #{request_signature}"
      text << "\n\n"
      text << stubbing_instructions(request_signature)
      text << request_stubs
      text << "\n\n" + "="*60
      super(text)
    end

    private

    def request_stubs
      return "" if WebMock::StubRegistry.instance.request_stubs.empty?
      text = "\n\nregistered request stubs:\n"
      WebMock::StubRegistry.instance.request_stubs.each do |stub|
        text << "\n#{WebMock::StubRequestSnippet.new(stub).to_s(false)}"
      end
      text
    end

    def stubbing_instructions(request_signature)
      text = ""
      request_stub = RequestStub.from_request_signature(request_signature)
      text << "You can stub this request with the following snippet:\n\n"
      text << WebMock::StubRequestSnippet.new(request_stub).to_s
      text
    end
  end

end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
whos_dated_who-0.1.0 vendor/bundle/gems/webmock-1.18.0/lib/webmock/errors.rb
whos_dated_who-0.0.1 vendor/bundle/gems/webmock-1.18.0/lib/webmock/errors.rb
webmock-1.18.0 lib/webmock/errors.rb
webmock-1.17.4 lib/webmock/errors.rb
webmock-1.17.3 lib/webmock/errors.rb
webmock-1.17.2 lib/webmock/errors.rb
webmock-1.17.1 lib/webmock/errors.rb
webmock-1.17.0 lib/webmock/errors.rb
webmock-1.16.1 lib/webmock/errors.rb
webmock-1.16.0 lib/webmock/errors.rb
webmock-1.15.2 lib/webmock/errors.rb
webmock-1.15.0 lib/webmock/errors.rb
webmock-1.14.0 lib/webmock/errors.rb