stub registry to keep track of StubbedRequest stubs
See also
Other stub-registry:
remove_request_stub()
,
stub_registry()
,
stub_registry_clear()
Methods
Method print()
print method for the StubRegistry
class
Method find_stubbed_request()
Find a stubbed request
Arguments
req
an object of class RequestSignature
Returns
an object of type StubbedRequest, if matched
Method request_stub_for()
Find a stubbed request
Arguments
request_signature
an object of class RequestSignature
count
(bool) iterate counter or not. default:
TRUE
Method remove_request_stub()
Remove a stubbed request by matching request signature
Arguments
stub
an object of type StubbedRequest
Method is_registered()
Find a stubbed request from a request signature
Arguments
x
an object of class RequestSignature
Method is_stubbed()
Check if a stubbed request is in the stub registry
Arguments
stub
an object of class StubbedRequest
Examples
if (FALSE) { # \dontrun{
# Make a stub
stub1 <- StubbedRequest$new(method = "get", uri = "api.crossref.org")
stub1$with(headers = list('User-Agent' = 'R'))
stub1$to_return(status = 200, body = "foobar", headers = list())
stub1
# Make another stub
stub2 <- StubbedRequest$new(method = "get", uri = "api.crossref.org")
stub2
# Put both stubs in the stub registry
reg <- StubRegistry$new()
reg$register_stub(stub = stub1)
reg$register_stub(stub = stub2)
reg
reg$request_stubs
} # }