That is clever. Move the global environment so that it is above (rather than below) the testing environment, in which case search should work.

If only R would allow that. The test environment is at pos=-1 (parent to global environment). So if we did attach(.GlobalEnv, pos=-2) things should work. Unfortunately, pos=-2 is not a valid position. R ignores this position setting and goes with the default (pos=2). So we are no better off.

Kenton White

On Dec 9, 2013, at 9:47 PM, Kirill Müller <notifications@github.com> wrote:

> In tests/3.R:
> 
> > @@ -12,12 +18,12 @@ variable.name <- ProjectTemplate:::clean.variable.name('example_01')
> >  
> >  ProjectTemplate:::csv.reader(data.file, filename, variable.name)
> >  
> > -expect_that(exists(variable.name), is_true())
> > -expect_that(names(get(variable.name)), equals(c('N', 'Prime')))
> > -expect_that(nrow(get(variable.name)), equals(5))
> > -expect_that(ncol(get(variable.name)), equals(2))
> > -expect_that(get(variable.name)[5, 2], equals(11))
> > -rm(example.01)
> > +expect_that(exists(variable.name, envir = env), is_true())
> attach can use environments, too. Not sure about the value of pos in our case, though.
> 
> —
> Reply to this email directly or view it on GitHub.
>