File: test-optionally.R

package info (click to toggle)
r-cran-reprex 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,584 kB
  • sloc: sh: 13; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,142 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
test_that("`session_info` can be set via option", {
  skip_on_cran()
  withr::with_options(
    list(reprex.session_info = TRUE),
    out <- reprex(1, render = FALSE)
  )
  expect_match(out, "session_*[iI]nfo", all = FALSE)
})

test_that("`advertise` can be set via option", {
  skip_on_cran()
  withr::with_options(
    list(reprex.advertise = FALSE),
    out <- reprex(1, render = FALSE)
  )
  expect_false(any(grepl("#+ reprex-ad", out, fixed = TRUE)))
})

test_that("`comment` can be set via option", {
  skip_on_cran()
  withr::with_options(
    list(reprex.comment = "#? "),
    out <- reprex(rnorm(1))
  )
  expect_match(out, "^#\\?", all = FALSE)
})

test_that("`tidyverse_quiet` can be set via option", {
  skip_on_cran()
  withr::with_options(
    list(reprex.tidyverse_quiet = FALSE),
    out <- reprex(mean(1:3), render = FALSE)
  )
  expect_match(out, "tidyverse_quiet: FALSE", fixed = TRUE, all = FALSE)
})

test_that("`std_out_err` can be set via option", {
  skip_on_cran()
  withr::with_options(
    list(reprex.std_out_err = TRUE),
    out <- reprex(1, render = FALSE)
  )
  expect_match(out, "std_out_err", all = FALSE)
})