webmockr: mock HTTP requests

, ,

Authors: Scott Chamberlain

webmockr is an R library for stubbing and setting expectations on HTTP requests.
It is a port of the Ruby gem webmock.

webmockr works by plugging in to another R package that does HTTP requests. It currently only works with crul right now, but we plan to add support for curl and httr later.

webmockr has the following high level features:

  • Stubbing HTTP requests at low http client level
  • Setting expectations on HTTP requests
  • Matching requests based any combination of HTTP method (e.g., GET/POST/PUT), URI (i.e., URL), request headers and body
  • Will soon integrate with vcr so that you can cache real HTTP responses - and easily integrate with testthat


Read the rest at https://ropensci.org/technotes/2018/02/20/webmockr-intro/