Skip to content

Commit

Permalink
tell r where to find fs functions in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crew102 committed Aug 31, 2018
1 parent 0eec4b6 commit bc66e15
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ expect_error_free <- function(...) {

## set wd to session temp dir, execute testing code, restore previous wd
temporarily <- function(env = parent.frame()) {
withr::local_dir(path_temp(), .local_envir = env)
withr::local_dir(fs::path_temp(), .local_envir = env)
}

## call during interactive test development to fake being "in tests" and thereby
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-filepaths.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test_that("make_filebase() defaults to 'reprex' inside a dir inside tempdir", {
x <- make_filebase(outfile = NULL, infile = NULL)
expect_equal(fs::path_file(x), "reprex")
expect_match(fs::path_file(fs::path_dir(x)), "^reprex")
temp <- fs::path_real(path_temp())
temp <- fs::path_real(fs::path_temp())
expect_identical(fs::path_common(c(x, temp)), temp)
})

Expand All @@ -22,9 +22,9 @@ test_that("make_filebase() works from relative infile, outfile", {
test_that("make_filebase() works from absolute infile, outfile", {
x <- make_filebase(outfile = NA, infile = fs::path_temp("abcde"))
expect_match(fs::path_file(x), "^abcde")
expect_equal(fs::path_dir(x), path_temp())
expect_equal(fs::path_dir(x), fs::path_temp())

x <- make_filebase(outfile = fs::path_temp("abcde"))
expect_match(fs::path_file(x), "^abcde")
expect_equal(fs::path_dir(x), path_temp())
expect_equal(fs::path_dir(x), fs::path_temp())
})
2 changes: 1 addition & 1 deletion tests/testthat/test-input.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test_that("newlines in code are protected and uniformly so across venues", {
input <- 'paste(letters[1:3], collapse = "\n")\n'
chr_input <- reprex(input = input, render = FALSE)

input_file <- path_temp("foo.R")
input_file <- fs::path_temp("foo.R")
withr::local_file(input_file)
writeLines(
escape_newlines('paste(letters[1:3], collapse = "\n")'),
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ context("utils")

test_that("locate_input() works", {
expect_identical("clipboard", locate_input(NULL))
expect_identical("path", locate_input(path_temp()))
expect_identical("path", locate_input(fs::path_temp()))
expect_identical("input", locate_input(c("a", "b")))
expect_identical("input", locate_input("a\n"))
})
Expand Down

0 comments on commit bc66e15

Please sign in to comment.