Skip to content

Commit

Permalink
Use ui_path() as it was designed to be used (r-lib#1861)
Browse files Browse the repository at this point in the history
* Use ui_path() as it was designed to be used

Closes r-lib#1859

* Add a test
  • Loading branch information
jennybc committed Jun 14, 2023
1 parent 044e19c commit 97b2891
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/write.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ write_union <- function(path, lines, quiet = FALSE) {
}

if (!quiet) {
ui_done("Adding {ui_value(new)} to {ui_path(proj_rel_path(path))}")
ui_done("Adding {ui_value(new)} to {ui_path(path)}")
}

all <- c(existing_lines, new)
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/_snaps/write.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# write_union() messaging is correct with weird working directory

Code
write_union(proj_path("somefile"), letters[4:6])
Message
v Adding 'd', 'e', 'f' to 'somefile'

12 changes: 12 additions & 0 deletions tests/testthat/test-write.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,15 @@ test_that("write_over() works for a file in a project that is not active", {
)
expect_false(proj_active())
})

test_that("write_union() messaging is correct with weird working directory", {
create_local_project()
withr::local_options(usethis.quiet = FALSE)

use_directory("aaa/bbb")
setwd("aaa/bbb")

expect_snapshot(
write_union(proj_path("somefile"), letters[4:6])
)
})

0 comments on commit 97b2891

Please sign in to comment.