Sha256: c5a603ed7db23797922c5057595091dde8df48e3799f98f507fab4efd8e25ca7

Contents?: true

Size: 1.62 KB

Versions: 34

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'

describe "errors" do
  describe WebMock::NetConnectNotAllowedError do
    describe "message" do
      it "should have message with request signature and snippet" do
        request_signature = mock(:to_s => "aaa")
        request_stub = mock
        WebMock::RequestStub.stub!(:from_request_signature).and_return(request_stub)
        WebMock::StubRequestSnippet.stub!(:new).
          with(request_stub).and_return(mock(:to_s => "bbb"))
        expected =  "Real HTTP connections are disabled. Unregistered request: aaa" +
               "\n\nYou can stub this request with the following snippet:\n\n" +
               "bbb\n\n============================================================"
        WebMock::NetConnectNotAllowedError.new(request_signature).message.should == expected
      end

      it "should have message with registered stubs if available" do
        request_signature = mock(:to_s => "aaa")
        request_stub = mock
        WebMock::StubRegistry.instance.stub!(:request_stubs).and_return([request_stub])
        WebMock::RequestStub.stub!(:from_request_signature).and_return(request_stub)
        WebMock::StubRequestSnippet.stub!(:new).
          with(request_stub).and_return(mock(:to_s => "bbb"))
        expected =  "Real HTTP connections are disabled. Unregistered request: aaa" +
               "\n\nYou can stub this request with the following snippet:\n\n" +
               "bbb\n\nregistered request stubs:\n\nbbb\n\n============================================================"
        WebMock::NetConnectNotAllowedError.new(request_signature).message.should == expected
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 3 rubygems

Version Path
simple-client-0.0.2 vendor/bundle/ruby/1.8/gems/webmock-1.8.8/spec/unit/errors_spec.rb
webmock-1.8.8 spec/unit/errors_spec.rb
webmock-1.8.7 spec/unit/errors_spec.rb
webmock-1.8.6 spec/unit/errors_spec.rb
webmock-1.8.5 spec/unit/errors_spec.rb
webmock-1.8.4 spec/unit/errors_spec.rb
webmock-1.8.3 spec/unit/errors_spec.rb
webmock-1.8.2 spec/unit/errors_spec.rb
webmock-1.8.1 spec/unit/errors_spec.rb
webmock-1.8.0 spec/unit/errors_spec.rb
webmock-1.7.10 spec/unit/errors_spec.rb
webmock-1.7.8 spec/unit/errors_spec.rb
webmock-1.7.7 spec/unit/errors_spec.rb
webmock-1.7.6 spec/unit/errors_spec.rb