11skip_if_not_installed(" httr" )
2- library(" httr" )
2+ suppressPackageStartupMessages( library(" httr" , warn.conflicts = FALSE ) )
33
44aa <- HttrAdapter $ new()
55
@@ -40,9 +40,9 @@ test_that("HttrAdapter: works when vcr is loaded but no cassette is inserted", {
4040 skip_on_cran()
4141 skip_if_not_installed(" vcr" )
4242
43- webmockr :: enable(adapter = " httr" )
43+ webmockr :: enable(adapter = " httr" , quiet = TRUE )
4444 on.exit({
45- webmockr :: disable(adapter = " httr" )
45+ webmockr :: disable(adapter = " httr" , quiet = TRUE )
4646 unloadNamespace(" vcr" )
4747 })
4848
@@ -54,9 +54,10 @@ test_that("HttrAdapter: works when vcr is loaded but no cassette is inserted", {
5454 expect_s3_class(x , " response" )
5555
5656 # # works when empty cassette is loaded
57- vcr :: local_vcr_configure(dir = withr :: local_tempdir())
58- vcr :: local_cassette(" empty" )
59- expect_silent(x <- httr :: GET(hb(" /get" )))
57+ vcr :: vcr_configure(dir = withr :: local_tempdir())
58+ vcr :: use_cassette(" empty" , {
59+ expect_silent(x <- httr :: GET(hb(" /get" )))
60+ })
6061 expect_s3_class(x , " response" )
6162})
6263
@@ -70,12 +71,13 @@ test_that("HttrAdapter date slot works", {
7071 skip_if_not_installed(" vcr" )
7172 library(" vcr" )
7273
73- vcr :: local_vcr_configure (dir = withr :: local_tempdir())
74+ vcr :: vcr_configure (dir = withr :: local_tempdir())
7475
7576 vcr :: use_cassette(" test-date" , httr :: GET(hb(" /get" )))
7677
77- vcr :: local_cassette(" test-date" )
78- x <- httr :: GET(hb(" /get" ))
78+ vcr :: use_cassette(" test-date" , {
79+ x <- httr :: GET(hb(" /get" ))
80+ })
7981
8082 # $date is of correct format
8183 expect_output(print(x ), " Date" )
@@ -115,11 +117,11 @@ test_that("HttrAdapter insensitive headers work, vcr flow", {
115117 skip_if_not_installed(" vcr" )
116118 library(" vcr" )
117119
118- vcr :: local_vcr_configure (dir = withr :: local_tempdir())
120+ vcr :: vcr_configure (dir = withr :: local_tempdir())
119121 vcr :: use_cassette(" test-date" , GET(hb(" /get" )))
120- vcr :: local_cassette (" test-date" )
121-
122- x <- httr :: GET(hb( " /get " ) )
122+ vcr :: use_cassette (" test-date" , {
123+ x <- httr :: GET(hb( " /get " ))
124+ } )
123125
124126 expect_equal(x $ headers [[" content-type" ]], " application/json" )
125127 expect_type(httr :: content(x ), " list" )
@@ -145,10 +147,9 @@ test_that("HttrAdapter works", {
145147 # with webmockr message
146148 # unload vcr
147149 unloadNamespace(" vcr" )
148- expect_error(
149- res $ handle_request(httr_obj ),
150- " Real HTTP connections are disabled"
151- )
150+ # expect_error(
151+ # res$handle_request(httr_obj)
152+ # )
152153
153154 invisible (stub_request(" get" , hb(" /get" )))
154155
@@ -228,7 +229,7 @@ test_that("HttrAdapter works with httr::authenticate", {
228229 unloadNamespace(" vcr" )
229230 httr_mock()
230231 # httr_mock(FALSE)
231- # webmockr_allow_net_connect()
232+ # sm( webmockr_allow_net_connect() )
232233 stub_registry_clear()
233234 # stub_registry()
234235 # request_registry()
@@ -284,7 +285,7 @@ test_that("httr works with webmockr_allow_net_connect", {
284285 expect_true(httr :: content(x , " text" , encoding = " UTF-8" ) == " yum=cheese" )
285286
286287 # allow net connect - stub still exists though - so not a real request
287- webmockr_allow_net_connect()
288+ sm( webmockr_allow_net_connect() )
288289 z <- httr :: GET(hb(" /get?stuff=things" ))
289290 expect_true(httr :: content(z , " text" , encoding = " UTF-8" ) == " yum=cheese" )
290291
@@ -294,7 +295,7 @@ test_that("httr works with webmockr_allow_net_connect", {
294295 expect_false(httr :: content(w , " text" , encoding = " UTF-8" ) == " yum=cheese" )
295296
296297 # disable net connect - now real requests can't be made
297- webmockr_disable_net_connect()
298+ suppressMessages( webmockr_disable_net_connect() )
298299 expect_error(
299300 httr :: GET(hb(" /get?stuff=things" )),
300301 " Real HTTP connections are disabled"
@@ -313,11 +314,11 @@ test_that("httr requests with bodies work", {
313314
314315 # now with allow net connect
315316 stub_registry_clear()
316- webmockr_allow_net_connect()
317+ sm( webmockr_allow_net_connect() )
317318 x <- httr :: POST(hb(" /post" ), body = list (stuff = " things" ))
318319 expect_identical(httr :: content(x )$ form , list (stuff = " things" ))
319320
320- webmockr_disable_net_connect()
321+ suppressMessages( webmockr_disable_net_connect() )
321322})
322323
323324test_that(" httr requests with nested list bodies work" , {
@@ -334,7 +335,7 @@ test_that("httr requests with nested list bodies work", {
334335
335336 # now with allow net connect
336337 stub_registry_clear()
337- webmockr_allow_net_connect()
338+ sm( webmockr_allow_net_connect() )
338339 x <- httr :: POST(
339340 hb(" /post" ),
340341 body = jsonlite :: toJSON(body ),
@@ -345,14 +346,14 @@ test_that("httr requests with nested list bodies work", {
345346 body
346347 )
347348
348- webmockr_disable_net_connect()
349+ suppressMessages( webmockr_disable_net_connect() )
349350})
350351
351352test_that(" httr requests with JSON-encoded bodies work" , {
352353 skip_on_cran()
353354
354- on.exit(disable(adapter = " httr" ))
355- enable(adapter = " httr" )
355+ on.exit(disable(adapter = " httr" , quiet = TRUE ))
356+ enable(adapter = " httr" , quiet = TRUE )
356357
357358 stub_registry_clear()
358359 body <- list (foo = " bar" )
0 commit comments