-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stubbing out a function called within S3 dispatch #43
Comments
This limitation doesn't really seem to cause many issues in practice, you usually would mock the generic rather than a method. |
Well ok, for whatever reason I was in the situation that I had written some tests using x <- structure(123, class = "cls")
testthat::with_mock(foo = function(x) "yay!", gen(x))
#> [1] "yay!" Then I switched to testthat 3e and found that with the current state of things I was not able to do the above using the advertised alternatives. Fine for me if you say this is not in-scope for 'mockery'. I'll close then. |
I just ran into this myself. It's not clear how to use
All of the following failed:
|
@MichaelChirico I started to roll my own, as I was not happy with what {mockery} and {mockr} offered in terms of functionality: {mockthat}. Has worked fine for my own use so far, but I'm sure there are edge-cases, that will break things for my approach too. Happy to take feedback/issues/etc. |
I'm running into issues trying to mock a function with S3 dispatch involved. Consider the following setting:
I would now like to be able to call
gen(x)
is a test wherefoo()
is stubbed out to avoid throwing the error. I assume this is currently not possible usingmockery::stub()
?The text was updated successfully, but these errors were encountered: