bblimke / webmock

Library for stubbing and setting expectations on HTTP requests in Ruby.
MIT License
3.98k stars 557 forks source link

`stub_request` no longer accepts `Addressable::URI` in webmock 3.24.0 #1082

Open postmodern opened 4 days ago

postmodern commented 4 days ago

In webmock 3.24.0, stub_request(method,uri) no longer accepts Addressable::URI objects.

      let(:uri) do
        Addressable::URI.new(
          scheme: 'http',
          host:   host,
          port:   port,
          path:   path
        )
      end

      it "must send a request with the given method and path to the host and return an Net::HTTPResponse object" do
        stub_request(method,uri)

        expect(subject.request(method,uri)).to be_kind_of(Net::HTTPResponse)

        expect(WebMock).to have_requested(method,uri)
      end
     Failure/Error: stub_request(method,uri)

     ArgumentError:
       URI should be a String, Regexp, Addressable::Template or a callable object. Got: Addressable::URI
     # /data/home/postmodern/code/ronin-rb/vendor/bundle/ruby/3.3.0/gems/webmock-3.24.0/lib/webmock/request_pattern.rb:92:in `create_uri_pattern'
     # /data/home/postmodern/code/ronin-rb/vendor/bundle/ruby/3.3.0/gems/webmock-3.24.0/lib/webmock/request_pattern.rb:21:in `initialize'
     # /data/home/postmodern/code/ronin-rb/vendor/bundle/ruby/3.3.0/gems/webmock-3.24.0/lib/webmock/request_stub.rb:9:in `new'
     # /data/home/postmodern/code/ronin-rb/vendor/bundle/ruby/3.3.0/gems/webmock-3.24.0/lib/webmock/request_stub.rb:9:in `initialize'
     # /data/home/postmodern/code/ronin-rb/vendor/bundle/ruby/3.3.0/gems/webmock-3.24.0/lib/webmock/api.rb:9:in `new'
     # /data/home/postmodern/code/ronin-rb/vendor/bundle/ruby/3.3.0/gems/webmock-3.24.0/lib/webmock/api.rb:9:in `stub_request'

This previously worked with webmock 3.23.1.

Earlopain commented 4 days ago

Some info in https://github.com/bblimke/webmock/pull/1073