Sha256: 1f3d63a152acf1c78b6ab7d2c2cf5cf0a7736b55ee9f6e337a5dced66e2bc02d

Contents?: true

Size: 990 Bytes

Versions: 40

Compression:

Stored size: 990 Bytes

Contents

module WebMock

  class NetConnectNotAllowedError < StandardError
    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

40 entries across 40 versions & 3 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/webmock-1.8.11/lib/webmock/errors.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/webmock-1.8.11/lib/webmock/errors.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/webmock-1.8.11/lib/webmock/errors.rb
webmock-1.13.0 lib/webmock/errors.rb
webmock-1.12.3 lib/webmock/errors.rb
webmock-1.12.2 lib/webmock/errors.rb
webmock-1.12.1 lib/webmock/errors.rb
webmock-1.12.0 lib/webmock/errors.rb
webmock-1.11.0 lib/webmock/errors.rb
webmock-1.10.2 lib/webmock/errors.rb
webmock-1.10.1 lib/webmock/errors.rb
webmock-1.10.0 lib/webmock/errors.rb
webmock-1.9.3 lib/webmock/errors.rb
webmock-1.9.2 lib/webmock/errors.rb
webmock-1.9.1 lib/webmock/errors.rb
simple-client-0.0.3 vendor/bundle/ruby/1.9.1/gems/webmock-1.8.8/lib/webmock/errors.rb
webmock-1.9.0 lib/webmock/errors.rb
webmock-1.8.11 lib/webmock/errors.rb
webmock-1.8.10 lib/webmock/errors.rb
webmock-1.8.9 lib/webmock/errors.rb