tests/testthat/test-graph.R

# Testing buildChapterGraph.
# library(testthat); library(rebook); source("test-graph.R")

dir <- tempfile()
dir.create(dir)
                                                     
tmp1 <- file.path(dir, "alpha.Rmd")
write(file=tmp1, "```{r, echo=FALSE, results='asis'}
rebook::chapterPreamble()
```

```{r}
rodan <- 1
```")
                                                     
tmp2 <- file.path(dir, "bravo.Rmd")
write(file=tmp2, "```{r, echo=FALSE, results='asis'}
rebook::chapterPreamble()
```

```{r}
extractCached('alpha.Rmd')
```")

test_that("building chapter graph works", {
    g <- buildChapterGraph(dir)
    expect_identical(names(igraph::V(g)), c("alpha.Rmd", "bravo.Rmd"))
    expect_true(igraph::are_adjacent(g, "alpha.Rmd", "bravo.Rmd"))
})

test_that("Makefile construction works", {
    createMakefile(dir)
    expect_true(file.exists(file.path(dir, "Makefile")))
})

Try the rebook package in your browser

Any scripts or data that you put into this service are public.

rebook documentation built on Nov. 8, 2020, 4:56 p.m.