Sha256: 1543c39281c2d1a46941d5dd2ee3936f1c6f7ce34ba4f0ccbd7970f95f1e8663

Contents?: true

Size: 1 KB

Versions: 12

Compression:

Stored size: 1 KB

Contents

module WebMock

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

    private

    def request_stubs
      return if WebMock::StubRegistry.instance.request_stubs.empty?
      text = "registered 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)
      return unless WebMock.show_stubbing_instructions?
      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

12 entries across 10 versions & 3 rubygems

Version Path
logstash-filter-zabbix-0.1.2 vendor/bundle/jruby/1.9/gems/webmock-1.21.0/lib/webmock/errors.rb
logstash-filter-zabbix-0.1.1 vendor/bundle/jruby/1.9/gems/webmock-1.21.0/lib/webmock/errors.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/webmock-1.20.4/lib/webmock/errors.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/webmock-1.20.4/lib/webmock/errors.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/webmock-1.20.4/lib/webmock/errors.rb
webmock-1.21.0 lib/webmock/errors.rb
webmock-1.20.4 lib/webmock/errors.rb
webmock-1.20.3 lib/webmock/errors.rb
webmock-1.20.2 lib/webmock/errors.rb
webmock-1.20.1 lib/webmock/errors.rb
webmock-1.20.0 lib/webmock/errors.rb
webmock-1.19.0 lib/webmock/errors.rb