Skip to content

Commit

Permalink
Merge branch 'main' into positron-git
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc authored Jun 28, 2024
2 parents 3d4f0e6 + 2663877 commit 8d63b39
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* `use_git()` no longer asks if you want to restart RStudio when using Positron.

* `use_test()` and `use_r()` now work when you are in `tests/testthat/_snaps/{foo}.md` (@olivroy, #1988).

* The URLs baked into the badge generated by `use_coverage(type = "codecov")`
no longer specify a branch (#2008).

Expand Down
4 changes: 2 additions & 2 deletions R/r.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ compute_active_name <- function(path, ext, error_call = caller_env()) {
path <- proj_path_prep(path_expand_r(path))

dir <- path_dir(proj_rel_path(path))
if (!dir %in% c("R", "src", "tests/testthat")) {
cli::cli_abort("Open file must be a code or test file.", call = error_call)
if (!dir %in% c("R", "src", "tests/testthat", "tests/testthat/_snaps")) {
cli::cli_abort("Open file must be code, test, or snapshot.", call = error_call)
}

file <- path_file(path)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/r.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
compute_active_name("foo/bar.R")
Condition
Error:
! Open file must be a code or test file.
! Open file must be code, test, or snapshot.

4 changes: 4 additions & 0 deletions tests/testthat/test-r.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ test_that("compute_active_name() standardises name", {
"bar.R"
)

expect_equal(
compute_active_name(path(dir, "tests/testthat/_snaps/bar.md"), "R"),
"bar.R"
)
# https://github.com/r-lib/usethis/issues/1690
expect_equal(
compute_active_name(path(dir, "R/data.frame.R"), "R"),
Expand Down

0 comments on commit 8d63b39

Please sign in to comment.