That's what I get for not testing it... A fix is just being tested by Travis.
@hadley: I need to mock github_pull_info for a unit test. I have a hack, but I was wondering if there are any recommended techniques. A StackOverflow search for [testthat] mock returned no results, and a post to R-devel hasn't been answered.
If I understand correctly, you want to put in a temporary replacement version of github_pull_info, because it's called by another function. Here's an idea for how to do this:
Create a new environment as a child of the namespace
Copy the function(s) to be tested into the new environment, and set their environment to the new environment.
Define the mock function (github_pull_info) in that environment
Call the functions that you want to test
There are some limitations of doing it this way. If you want to call the mock function indirectly (via another function that's not copied to the new environment), it won't work right. To get around this issue, you could copy over everything from the namespace into the new environment, and simply replace the mocked function, but this could be slow if you're running a lot of tests.
All of this is overkill for this one test, but it's a way you could do mocking in general.
install_github("hadley/ggplot2#878")fails with "Must specify either a ref or a pull request".
Can you take a look @krlmlr?
The text was updated successfully, but these errors were encountered: