test_that("trailing slash behaviour of ui_path()", {
  # target doesn't exist so no empirical evidence that it's a directory
  expect_match(ui_path("abc"), "abc'$")

  # path suggests it's a directory
  expect_match(ui_path("abc/"), "abc/'$")
  expect_match(ui_path("abc//"), "abc/'$")

  # path is known to be a directory
  tmpdir <- fs::file_temp(pattern = "ui_path")

  expect_match(ui_path(tmpdir), "/'$")
  expect_match(ui_path(paste0(tmpdir, "/")), "[^/]/'$")
  expect_match(ui_path(paste0(tmpdir, "//")), "[^/]/'$")

Try the usethis package in your browser

Any scripts or data that you put into this service are public.

usethis documentation built on July 4, 2019, 5:05 p.m.