Skip to content

Releases: ropensci/webmockr

webmockr v2.2.0

21 Jul 16:44
bb2876c

Choose a tag to compare

Changes

  • webmockr is no longer integrated with vcr; the two packages used to depend on one another, but no longer do. this should not impact your usage of webmockr (#149) (#150)
  • better implementation of quiet in enable()/disable() (#146) thanks @hadley
  • eliminate partial match warnings (#147) thanks @hadley

Full Changelog: v2.1.0...v2.2.0

webmockr v2.1.0

30 Jun 06:03
6a6b9d5

Choose a tag to compare

What's Changed

  • Many previously exported R6 classes that are internal use only are no longer exported. RequestPattern is still exported in this version, but will not be in the next version
  • Improve how httr2 mocking is set (#114) thanks @hadley
  • Correctly check that vcr is loaded, not attached (#142) thanks @hadley
  • Update tests to use testthat edition 3, and run in parallel
  • Moved crul from Imports to Suggests. replace use of a crul function with an equivalent from curl so crul is truly not needed to run wemockr unless using crul

New Contributors

Full Changelog: v2.0.0...v2.1.0

webmockr v2.0.0

11 Feb 20:36
ccd9398

Choose a tag to compare

Breaking changes

  • Previous to this version when stubs were constructed starting with stub_request() if an error occurred in a pipe chain, or non-pipe flow, the stub prior to the error remained. This was not correct behavior from a logical perspective - i.e., one would expect if an error occurred that thing they were trying to do did not stick around. The new behavior as of this version deletes the stub upon any error during its creation. Under the hood we're using withCallingHandlers to handle different types of errors, throw warnings, etc.

NEW FEATURES

  • Partial matching. New functions including() and excluding() for use with wi_th() support partial for bodies and queries (header partial matching was already supported without any additional steps). See ?partial. This makes it slightly to a whole lot easier to do matching depending on the HTTP request your trying to match (e.g., let's say you're trying to match against a query with 20 parameters - if you can match uniquely to it with 1 or 2 of those params, then you're all set) (#38)
  • Basic auth internal work for RequestPattern. Shouldn't change behavior (#133)
  • New features for supporting request body diffs. There are two ways to use request body diffing. First, you can toggle it on/off globally like webmockr_configure(show_body_diff = TRUE) or webmockr_configure(show_body_diff = FALSE). Second, a new function stub_body_diff() is a standalone function that compares by default the last stub created and the last http request made - but you can pass in any stub and http request. Note that body diffing functionality requires the suggested package diffobj (#126)
  • As part of the above body diffing functionality, two new functions are offered: last_request() and last_stub(), which get the last http request made and the last webmockr stub created, respectively. (#126)

MINOR IMPROVEMENTS

  • Removed global_stubs field from the StubRegistry class as it was completely unused (holdover from the initial port from Ruby). Should not impact users at all. (#127)
  • Wider use of rlang functions throughout the package for nicer assertions and condition handling. This change alters the main error message you get when there's no match to registered stubs. Hopefully this feels like an improvement to you; let me know. (#129)
  • StubRegistry gains new method is_stubbed() to check if a stub is in the stub registry

webmockr v1.0.0

22 Jul 15:54
93adc3a

Choose a tag to compare

NEW FEATURES

  • webmockr now supports the httr2 library, in addition to httr and crul. Note that you'll see different behavior from httr2 relative to the other 2 http clients because it turns http errors (http statuses 400 and above) into R errors (#122)
  • webmockr can now mock async http requests with crul (w/ crul v1.5 or greater). no change was required in webmockr for this to happen. a PR was merged in crul to hook into webmockr. there's no support for async in httr as that package does not do any async and no support in httr2 because req_perform_parallel does not have a mocking hook as does req_perform (#124)

webmockr v0.9.0

28 Feb 14:33
5299cbb

Choose a tag to compare

BUG FIXES

  • to_return() supports returning multiple responses to match many requests to the same matching stub. however, the internals were broken for this, but is now fixed (#115) thanks @kenahoo for the report
  • matching stubs with specifying a request body to match on (e.g., stub_request('post', 'https://httpbin.org/post') %>% wi_th(body = list(a=5))) was not working in some cases; internal matching logic was borked. now fixed. (#118) thanks @konradoberwimmer for the report
  • The status parameter in to_return() was documented to accept an integer, but it errored when an integer was passed (e.g., to_return(status=200L)). This bug is now fixed (#117) thanks @maelle for the report

MINOR IMPROVEMENTS

  • Config options changes (see webmockr_configure()). Three options that were presentg but not implemented are now removed: show_body_diff, query_values_notation, net_http_connect_on_start. One option that was present but not implemented yet is now implemented: show_stubbing_instructions (#27) (#120)

DOCUMENTATION

webmockr v0.8.2

28 Aug 19:51
ce0ffed

Choose a tag to compare

BUG FIXES

  • change to UriPattern to make sure regex matching is working as intended (#114) thanks @kenahoo

webmockr v0.8.0

13 Mar 20:27
d366de7

Choose a tag to compare

NEW FEATURES

  • enable() and the enable() method on the Adapter R6 class gain new parameter quiet to toggle whether messages are printed or not (#112)

MINOR IMPROVEMENTS

  • to re-create http response objects for both httr and crul we were using the url from the request object; now we use the url from the response object, BUT if there is no url in the response object we fall back to using the url from the request object (#110) (#113)
  • improve docs: add further explanation to manual files for both to_raise() and to_return() to explain the differenc between them and when you may want to use them (#100)

webmockr v0.7.4

09 Dec 00:06
a8acabe

Choose a tag to compare

MINOR IMPROVEMENTS

  • to support vcr being able to recreate httr objects fully (see github issue ropensci/vcr#132) we needed to handle additional parts of httr request objects: fields and output - with this change vcr should return objects much closer to what real httr requests return (#109)

BUG FIXES

  • bug fix + improvement: fixes for simple authentication - wi_th() now supports basic_auth to mock basic authentication either with crul::auth() or httr::authenticate() (#108)

webmockr v0.7.0

30 Sep 16:15
9d7caaf

Choose a tag to compare

NEW FEATURES

  • Gains ability to define more than 1 returned HTTP response, and the order in which the HTTP responses are returned. The idea is from the Ruby webmock library, but the implementation is different because the Ruby and R languages are very different. You can give more than one to_return() one creating a stub, or if you want to return the same response each time, you can use the new times parameter within to_return(). As a related use case (#31) you can mock http retry's using this new feature (#10) (#32) (#101)
  • Gains new function webmockr_reset() to be able to reset stub registry and request registry in one function call (#97) (#101)
  • Gains support for mocking simple authentication. wi_th() now accepts basic_auth in addition to query, body, and headers. Note that authentication type is ignored (#103)

MINOR IMPROVEMENTS

  • change to how URI's are matched in stub_request(): we weren't allowing matching URI's without schemes; you can now do that. In addition, webmockr can match URI's without the "http" scheme, but does not match if the scheme is "https". See UriPattern for more (#102)
  • another change to how URI's are matched: now query params compared separately to the URI; note that regex not allowed in query params (#104) - And now query parameters are compared with the same code both when regex uri is used and when it is not (#107)
  • URI matching for stubs is now done only on the URI's themselves; that is, query parameters are removed before comparison, so only the base url with http scheme, plus paths, are compared (#107)
  • wasn't sure write_disk_path behavior was correct when using httr, seems to be working, added tests for it (#79)
  • values for query parameters given to wi_th() are now all coerced to character class to make sure that all comparisons of stubs and requests are done with the same class (character) (#107)

BUG FIXES

  • fix for uri_regex usage in stub_request(): no longer curl escape the uri_regex given, only escape a non-regex uri (#106)

webmockr v0.6.2

24 Mar 20:38

Choose a tag to compare

  • change to CrulAdapter: do not use normalizePath on the write_disk_path path so that relative paths are not changed to full paths - added tests for this (#95) (#96)