library(httr)
# without_internet provides required mock context for expectations
without_internet({
expect_GET(
GET("http://httpbin.org/get"),
"http://httpbin.org/get"
)
expect_GET(GET("http://httpbin.org/get"),
"http://httpbin.org/[a-z]+",
fixed = FALSE
) # For regular expression matching
expect_PUT(
PUT("http://httpbin.org/put", body = '{"a":1}'),
"http://httpbin.org/put",
'{"a":1}'
)
expect_PUT(PUT("http://httpbin.org/put", body = '{"a":1}'))
expect_no_request(rnorm(5))
})
Run the code above in your browser using DataLab