@@ -70,21 +70,21 @@ test_that("write_over() leaves file 'as is'", {
7070})
7171
7272# https://github.com/r-lib/usethis/issues/514
73- test_that(" write_ut8 always produces a trailing newline" , {
73+ test_that(" write_utf8() always produces a trailing newline" , {
7474 path <- file_temp()
7575 write_utf8(path , " x" , line_ending = " \n " )
7676 expect_equal(readChar(path , 2 ), " x\n " )
7777})
7878
79- test_that(" write_ut8 can append text when requested" , {
79+ test_that(" write_utf8() can append text when requested" , {
8080 path <- file_temp()
8181 write_utf8(path , " x" , line_ending = " \n " )
8282 write_utf8(path , " x" , line_ending = " \n " , append = TRUE )
8383
8484 expect_equal(readChar(path , 4 ), " x\n x\n " )
8585})
8686
87- test_that(" write_utf8 respects line ending" , {
87+ test_that(" write_utf8() respects line ending" , {
8888 path <- file_temp()
8989
9090 write_utf8(path , " x" , line_ending = " \n " )
@@ -93,3 +93,15 @@ test_that("write_utf8 respects line ending", {
9393 write_utf8(path , " x" , line_ending = " \r\n " )
9494 expect_equal(detect_line_ending(path ), " \r\n " )
9595})
96+
97+ test_that(" write_utf8() can operate outside of a project" , {
98+ tmpdir <- file_temp()
99+ on.exit(dir_delete(tmpdir ))
100+ dir_create(tmpdir )
101+
102+ withr :: local_dir(tmpdir )
103+ local_project(NULL )
104+
105+ expect_false(proj_active())
106+ expect_error_free(write_utf8(path = " foo" , letters [1 : 3 ]))
107+ })
0 commit comments