-
Allow
with(query: :any)to match any query string (#1099)stub_request(:get, "www.example.com").with(query: :any)matches requests with any query string, or none. RSpec'sanythingworks the same way. Previously, this raisedNoMethodError, and you had to writewith(query: hash_including({})).Use a URL without query parameters when passing
query: :any. Otherwise, WebMock raisesArgumentError.Thanks to nightpool
-
Raise a clear
ArgumentErrorfor an unsupportedqueryoptionPreviously, a value such as
with(query: :all)raisedNoMethodError(undefined methodsplit). The new error lists the supported values. -
Show
anythingfor keys given without a value tohash_includingorhash_excludingoutside RSpecPreviously, with Minitest or Test::Unit, messages showed
#<WebMock::Matchers::AnyArgMatcher:0x...>, for example forwith(query: hash_including(:a)). RSpec's own matchers already showedanything. -
Provide
HTTP_HOSTtoto_rackapps when the client has not supplied a Host header (#1084)Previously, requests from some HTTP clients reached the Rack app without
HTTP_HOST. This caused host checks such as Sinatra'sHostAuthorizationto see an empty host.WebMock now fills in the host from the request URL, including the port when it is not the default. An explicit Host header is preserved.
Thanks to Benoit Tigeot
-
Fix Rack compatibility for
to_rackappsThe request environment now passes
Rack::Lint.SERVER_PORTandCONTENT_LENGTHare now strings. If your app or tests read them directly, use string comparisons, such asenv['SERVER_PORT'] == "80". The environment also includesSERVER_PROTOCOL.CONTENT_TYPEis omitted when the request has no content type. TheContent-Lengthheader is passed only asCONTENT_LENGTH, without an extraHTTP_CONTENT_LENGTHentry.Transfer-Encodingis removed because the body has already been decoded.Repeated header values are joined into one string. Header values and the body read from
rack.inputnow use binary (ASCII-8BIT) strings.