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

Cannot access variables declared outside the with_mock function #193

Closed
andreea-bogdan opened this Issue Oct 28, 2014 · 2 comments

Comments

Projects
None yet
3 participants
@andreea-bogdan

andreea-bogdan commented Oct 28, 2014

R version: 3.1.0
testthat: 0.9.1

Small example of the problem

test_that( "test",
          {
            value <- 1.5
            with_mock(
              expect_equal(2 * 3, 4),
              all.equal = function(x, y, ...) {value}
            )
          }
)

If I am executing the above code snippet through the “Test package” button in RStudio, then I get the error:

“1. Error: test -----------------------------------------------------------------
object 'value' not found”

Currently it seems it is not possible to reference from the mocked function variables which are declared outside the scope of the with_mock function

@krlmlr

This comment has been minimized.

Member

krlmlr commented Jan 5, 2015

@andreea-bogdan: Thanks for reporting this. Could you please test my pull request? Install with devtools::install_github("hadley/devtools#207")

@hadley

This comment has been minimized.

Member

hadley commented Jan 7, 2015

Should be fixed now.

@hadley hadley closed this Jan 7, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment