Skip to content

Commit 7ffd844

Browse files
committed
Add a test for rendering the purl script
1 parent f143f58 commit 7ffd844

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Purl Test Document
3+
toc-title: Table of contents
4+
---
5+
6+
Hello, world
7+
8+
:::: cell
9+
``` {.r .cell-code}
10+
cat("more")
11+
```
12+
13+
::: {.cell-output .cell-output-stdout}
14+
more
15+
:::
16+
::::

tests/testthat/test-utils-extract.R

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test_that("extract_r_code() errors on existing script", {
1717
)
1818
})
1919

20-
test_that("extract_r_code() writes metadata", {
20+
test_that("extract_r_code() writes R file that renders", {
2121
skip_if_no_quarto()
2222
r_script <- withr::local_tempfile(pattern = "purl", fileext = ".R")
2323

@@ -30,6 +30,20 @@ test_that("extract_r_code() writes metadata", {
3030
),
3131
name = "purl.R"
3232
)
33+
34+
skip_if_no_quarto("1.4.511")
35+
announce_snapshot_file(name = "purl.md")
36+
md_file <- xfun::with_ext(r_script, "md")
37+
quarto::quarto_render(
38+
r_script,
39+
output_format = "markdown",
40+
output_file = basename(md_file),
41+
quiet = TRUE
42+
)
43+
expect_snapshot_file(
44+
path = md_file,
45+
name = "purl.md"
46+
)
3347
})
3448

3549
test_that("extract_r_code() do nothing on file with no code", {

0 commit comments

Comments
 (0)