diff --git a/R/topics.R b/R/topics.R index de61e11cf..b43c75091 100644 --- a/R/topics.R +++ b/R/topics.R @@ -134,7 +134,7 @@ match_env <- function(topics) { } fns$has_lifecycle <- function(x) { check_string(x) - which(purrr::map_lgl(topics$lifecycle, ~ any(.$name %in% x))) + which(purrr::map_lgl(topics$lifecycle, ~ any(. %in% x))) } fns$has_concept <- function(x, internal = FALSE) { check_string(x) diff --git a/tests/testthat/test-topics.R b/tests/testthat/test-topics.R index a4c9c5d5d..ee8be76f6 100644 --- a/tests/testthat/test-topics.R +++ b/tests/testthat/test-topics.R @@ -119,6 +119,16 @@ test_that("can select by keyword", { expect_equal(select_topics("has_keyword('c')", topics), integer()) }) +test_that("can select by lifecycle", { + topics <- tibble::tribble( + ~name, ~alias, ~internal, ~keywords, ~lifecycle, + "b1", "b1", FALSE, "a", list("stable"), + "b2", "b2", FALSE, c("a", "b"), NULL + ) + expect_equal(select_topics("has_lifecycle('stable')", topics), 1) + expect_equal(select_topics("has_lifecycle('deprecated')", topics), integer()) +}) + test_that("can combine positive and negative selections", { topics <- tibble::tribble( ~name, ~alias, ~internal,