File path checking seems to go wrong when use_test() tries to get the path to the active file in RStudio in a project under ~ on Windows:
usethis::use_r("foo.R")
# ✔ Setting active project to 'C:/Users/mikko/Documents/R/dev/foo'
# ● Modify 'R/foo.R'
usethis::use_test()
# ✔ Adding 'testthat' to Suggests field in DESCRIPTION
# ✔ Creating 'tests/testthat/'
# ✔ Writing 'tests/testthat.R'
# ● Call `use_test()` to initialize a basic test file and open it for editing.
# Error: Open file must be in the 'R/' directory of the active package.
# * Actual path: 'Users/mikko/R/dev/foo/R/foo.R'
rstudioapi::getSourceEditorContext()$path
# [1] "~/R/dev/foo/R/foo.R"
usethis:::proj_path_prep(rstudioapi::getSourceEditorContext()$path)
# C:/Users/mikko/Documents/R/dev/foo/Users/mikko/R/dev/foo/R/foo.R
Related r-lib/fs#221. Maybe related #485?