Skip to content

Commit

Permalink
fix #127 remove global_stubs from StubRegistry - not used
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Nov 5, 2024
1 parent 41974a6 commit 1506b51
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
7 changes: 2 additions & 5 deletions R/StubRegistry.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ StubRegistry <- R6::R6Class(
public = list(
#' @field request_stubs (list) list of request stubs
request_stubs = list(),
#' @field global_stubs (list) list of global stubs
global_stubs = list(),

#' @description print method for the `StubRegistry` class
#' @param x self
Expand All @@ -51,8 +49,7 @@ StubRegistry <- R6::R6Class(
#' @param req an object of class [RequestSignature]
#' @return an object of type [StubbedRequest], if matched
find_stubbed_request = function(req) {
stubs <- c(self$global_stubs, self$request_stubs)
stubs[self$request_stub_for(req)]
self$request_stubs[self$request_stub_for(req)]
},

# response_for_request = function(request_signature) {
Expand All @@ -65,7 +62,7 @@ StubRegistry <- R6::R6Class(
#' @param count (bool) iterate counter or not. default: `TRUE`
#' @return logical, 1 or more
request_stub_for = function(request_signature, count = TRUE) {
stubs <- c(self$global_stubs, self$request_stubs)
stubs <- self$request_stubs
mtchs <- vapply(stubs, function(z) {
tmp <- RequestPattern$new(method = z$method, uri = z$uri,
uri_regex = z$uri_regex, query = z$query,
Expand Down
2 changes: 0 additions & 2 deletions man/StubRegistry.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions tests/testthat/test-StubRegistry.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ test_that("StubRegistry: bits are correct prior to having data", {

expect_is(aa, "StubRegistry")

expect_is(aa$global_stubs, "list")
expect_equal(length(aa$global_stubs), 0)

expect_is(aa$request_stubs, "list")
expect_equal(length(aa$request_stubs), 0)

Expand Down Expand Up @@ -39,10 +36,6 @@ test_that("StubRegistry: bits are correct after having data", {

expect_is(aa, "StubRegistry")

# global stubs are still empty
expect_is(aa$global_stubs, "list")
expect_equal(length(aa$global_stubs), 0)

# request stubs now length 2
expect_is(aa$request_stubs, "list")
expect_equal(length(aa$request_stubs), 2)
Expand Down

0 comments on commit 1506b51

Please sign in to comment.