Closed
Description
I'm running into issues trying to mock a function with S3 dispatch involved. Consider the following setting:
gen <- function(x) UseMethod("gen")
met <- function(x) foo(x)
foo <- function(x) stop("foo")
.S3method("gen", "cls", met)
x <- structure(123, class = "cls")
gen(x)
#> Error in foo(x) : foo
I would now like to be able to call gen(x)
is a test where foo()
is stubbed out to avoid throwing the error. I assume this is currently not possible using mockery::stub()
?
mockery::stub(gen, "foo", "bar", depth = 1)
gen(x)
#> Error in foo(x) : foo
mockery::stub(gen, "foo", "bar", depth = 2)
gen(x)
#> Error in foo(x) : foo
mockery::stub(gen, "foo", "bar", depth = 3)
gen(x)
#> Error in foo(x) : foo
# etc...
Metadata
Metadata
Assignees
Labels
No labels