Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove S4 class after test #1565

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/rd.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ roclet_process.roclet_rd <- function(x, blocks, env, base_path) {
topics_add_default_description(topics)
topics_add_package_alias(topics)

topics$topics
structure(topics$topics, env = env)
}

#' @export
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/rd-describe-in.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@

}}

---
# s4 methods get nice label (2)

Code
out$get_section("minidesc")
Expand Down
17 changes: 13 additions & 4 deletions tests/testthat/test-rd-describe-in.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ test_that("infix and replacement names get nice label", {
})

test_that("s4 methods get nice label", {
out <- roc_proc_text(rd_roclet(), "
proc <- roc_proc_text(rd_roclet(), "
#' Class
#'
setClass('foo1', slots = c(id = 'character'))
Expand All @@ -211,10 +211,15 @@ test_that("s4 methods get nice label", {

#' @describeIn foo1 function
setMethod('m_id', 'foo1', function(x) x@id)
")[[1]]
")
expect_type(attr(proc, "env"), "environment")
withr::defer(removeClass("foo1", attr(proc, "env")))
out <- proc[[1]]
expect_snapshot(out$get_section("minidesc"))
})

out <- roc_proc_text(rd_roclet(), "
test_that("s4 methods get nice label (2)", {
proc <- roc_proc_text(rd_roclet(), "
setClass('foo2')
setClass('foo3')

Expand All @@ -225,7 +230,11 @@ test_that("s4 methods get nice label", {
setMethod('bar1', c('foo2', 'foo3'), function(x, y) 1)
#' @describeIn bar1 method2
setMethod('bar1', c('foo3', 'foo2'), function(x, y) 1)
")[[1]]
")
expect_type(attr(proc, "env"), "environment")
withr::defer(removeClass("foo2", attr(proc, "env")))
withr::defer(removeClass("foo3", attr(proc, "env")))
out <- proc[[1]]
expect_snapshot(out$get_section("minidesc"))
})

Expand Down
Loading