gems webmock 4.4.0

one hour ago
  • Show request body differences when assert_requested or an RSpec request expectation fails (#825)

    If your test expects POST /orders with "total": 10 in the JSON body and the request omits that field, the failure message now shows total: expected 10, but the field was missing. Previously, you had to find the difference in the request history. WebMock shows a short diff when one distinct request matches the method and URL and its body explains the mismatch.

    For multiline XML and plain text, the diff shows line numbers, with - for expected lines and + for lines actually sent. This uses the diff-lcs gem. Unregistered request errors previously printed JSON differences as arrays such as ["+", "total", 10]. They now use the same wording and skip stubs with a different method or URL. When several JSON fields differ, both messages show the expected and recorded bodies if that takes no more space than listing the changes.

    Thanks to Adrian1707 and odinhb for the examples.

  • Fix IOError: ungetbyte failed when matching large file uploads

    With Curb, Patron or em-http-request, even calling file.eof? before an upload could trigger the error and leave the file at the end. WebMock now matches and records the bytes from the current position and leaves the file ready for the HTTP client to read.

Don't miss a new webmock release

NewReleases is sending notifications on new releases.