1- context(" CrulAdapter" )
2-
31aa <- CrulAdapter $ new()
42
53test_that(" CrulAdapter bits are correct" , {
64 skip_on_cran()
75
8- expect_is (CrulAdapter , " R6ClassGenerator" )
6+ expect_s3_class (CrulAdapter , " R6ClassGenerator" )
97
10- expect_is (aa , " CrulAdapter" )
8+ expect_s3_class (aa , " CrulAdapter" )
119 expect_null(aa $ build_crul_request ) # pulled out of object, so should be NULL
1210 expect_null(aa $ build_crul_response ) # pulled out of object, so should be NULL
13- expect_is (aa $ disable , " function " )
14- expect_is (aa $ enable , " function " )
15- expect_is (aa $ handle_request , " function " )
16- expect_is (aa $ remove_stubs , " function " )
17- expect_is (aa $ name , " character" )
11+ expect_type (aa $ disable , " closure " )
12+ expect_type (aa $ enable , " closure " )
13+ expect_type (aa $ handle_request , " closure " )
14+ expect_type (aa $ remove_stubs , " closure " )
15+ expect_type (aa $ name , " character" )
1816
1917 expect_equal(aa $ name , " CrulAdapter" )
2018})
@@ -52,17 +50,16 @@ test_that("CrulAdapter: works when vcr is loaded but no cassette is inserted", {
5250 cli <- crul :: HttpClient $ new(hb())
5351
5452 expect_silent(x <- cli $ get(" get" ))
55- expect_is (x , " HttpResponse" )
53+ expect_s3_class (x , " HttpResponse" )
5654
5755 # works when empty cassette is loaded
5856 vcr :: vcr_configure(dir = tempdir())
5957 vcr :: insert_cassette(" empty" )
6058 expect_silent(x <- cli $ get(" get" ))
6159 vcr :: eject_cassette()
62- expect_is (x , " HttpResponse" )
60+ expect_s3_class (x , " HttpResponse" )
6361})
6462
65- context(" CrulAdapter - with real data" )
6663test_that(" CrulAdapter works" , {
6764 skip_on_cran()
6865 skip_if_not_installed(" vcr" )
@@ -90,8 +87,8 @@ test_that("CrulAdapter works", {
9087
9188 aa <- res $ handle_request(crul_obj )
9289
93- expect_is (res , " CrulAdapter" )
94- expect_is (aa , " HttpResponse" )
90+ expect_s3_class (res , " CrulAdapter" )
91+ expect_s3_class (aa , " HttpResponse" )
9592 expect_equal(aa $ method , " get" )
9693 expect_equal(aa $ url , " http://localhost:9000/get" )
9794
@@ -109,17 +106,17 @@ test_that("CrulAdapter works", {
109106
110107 aa <- res $ handle_request(crul_obj )
111108
112- expect_is (res , " CrulAdapter" )
113- expect_is (aa , " HttpResponse" )
109+ expect_s3_class (res , " CrulAdapter" )
110+ expect_s3_class (aa , " HttpResponse" )
114111 expect_equal(aa $ method , " get" )
115112 expect_equal(aa $ url , " http://localhost:9000/get" )
116113
117114 # has response_headers and response_headers_all
118115 expect_equal(length(aa $ response_headers ), 1 )
119- expect_is (aa $ response_headers , " list" )
116+ expect_type (aa $ response_headers , " list" )
120117 expect_named(aa $ response_headers , " user-agent" )
121118 expect_equal(length(aa $ response_headers_all ), 1 )
122- expect_is (aa $ response_headers_all , " list" )
119+ expect_type (aa $ response_headers_all , " list" )
123120 expect_named(aa $ response_headers_all , NULL )
124121 expect_named(aa $ response_headers_all [[1 ]], " user-agent" )
125122
@@ -145,12 +142,12 @@ test_that("CrulAdapter works", {
145142
146143 # has response_headers and response_headers_all
147144 expect_equal(length(aa $ response_headers ), 2 )
148- expect_is (aa $ response_headers , " list" )
145+ expect_type (aa $ response_headers , " list" )
149146 expect_equal(sort(names(aa $ response_headers )), c(" location" , " status" ))
150147 expect_equal(length(aa $ response_headers_all ), 1 )
151148 expect_equal(length(aa $ response_headers_all [[1 ]]), 2 )
152- expect_is (aa $ response_headers_all , " list" )
153- expect_is (aa $ response_headers_all [[1 ]], " list" )
149+ expect_type (aa $ response_headers_all , " list" )
150+ expect_type (aa $ response_headers_all [[1 ]], " list" )
154151 expect_named(aa $ response_headers_all , NULL )
155152 expect_equal(
156153 sort(names(aa $ response_headers_all [[1 ]])),
0 commit comments