@@ -23,27 +23,6 @@ test_that("codebook generation", {
2323})
2424
2525
26- test_that(" codebook generation via helper fun" , {
27- data(" bfi" , package = ' codebook' )
28- library(dplyr )
29- bfi <- bfi %> % select(- starts_with(" BFIK_extra" ),
30- - starts_with(" BFIK_agree" ),
31- - starts_with(" BFIK_open" ))
32- bfi $ age <- 1 : nrow(bfi )
33- wd <- getwd()
34- dir <- tempdir()
35- setwd(dir )
36- on.exit(setwd(wd ))
37- saveRDS(bfi , " bfi.rds" )
38- expect_message(md <- load_data_and_render_codebook(" bfi.rds" ,
39- "
40- ```{r}
41- codebook(codebook_data)
42- ```
43- " ))
44- })
45-
46-
4726test_that(" codebook generation without formr" , {
4827 data(" bfi" , package = ' codebook' )
4928 library(dplyr )
@@ -72,9 +51,11 @@ test_that("Codebook with retest reliabilities can be computed", {
7251 library(dplyr )
7352 bfi <- bfi %> % select(- starts_with(" BFIK_extra" ),
7453 - starts_with(" BFIK_agree" ),
75- - starts_with(" BFIK_open" ))
54+ - starts_with(" BFIK_open" ),
55+ - starts_with(" BFIK_consc" ))
7656 expect_warning(bfi2 <- bind_rows(bfi , bfi %> %
77- mutate(created = created + lubridate :: years(1 ))))
57+ mutate(created = created + lubridate :: years(1 ),
58+ ended = ended + lubridate :: years(1 ))))
7859
7960
8061
@@ -87,9 +68,8 @@ test_that("Codebook with retest reliabilities can be computed", {
8768 on.exit(setwd(wd ))
8869 expect_silent(md <- codebook(bfi2 ))
8970 figs <- list.files(paste0(dir , " /figure" ))
90- expect_equal(length(figs ), 8 )
71+ expect_equal(length(figs ), 6 )
9172 expect_match(md , " Scale: BFIK_neuro" )
92- expect_match(md , " Scale: BFIK_consc" )
9373 expect_match(md , " Missings per variable" )
9474 expect_match(md , " 56 completed rows" )
9575
@@ -108,11 +88,16 @@ test_that("Codebook with multilevel reliability", {
10888 bfi $ age <- 1 : nrow(bfi )
10989 fuzz <- function (x ) { x + rnorm(length(x )) }
11090 expect_warning(bfi3 <- bind_rows(bfi ,
111- bfi %> % mutate(created = created + lubridate :: days(1 )),
112- bfi %> % mutate(created = created + lubridate :: days(2 )),
113- bfi %> % mutate(created = created + lubridate :: days(3 )),
114- bfi %> % mutate(created = created + lubridate :: days(4 )),
115- bfi %> % mutate(created = created + lubridate :: days(5 ))
91+ bfi %> % mutate(created = created + lubridate :: days(1 ),
92+ ended = ended + lubridate :: days(1 )),
93+ bfi %> % mutate(created = created + lubridate :: days(2 ),
94+ ended = ended + lubridate :: days(2 )),
95+ bfi %> % mutate(created = created + lubridate :: days(3 ),
96+ ended = ended + lubridate :: days(3 )),
97+ bfi %> % mutate(created = created + lubridate :: days(4 ),
98+ ended = ended + lubridate :: days(4 )),
99+ bfi %> % mutate(created = created + lubridate :: days(5 ),
100+ ended = ended + lubridate :: days(5 ))
116101 ) %> % mutate_at(vars(matches(" _\\ d" )), fuzz ))
117102 bfi3 <- rescue_attributes(bfi3 , bfi )
118103
@@ -122,10 +107,32 @@ test_that("Codebook with multilevel reliability", {
122107 on.exit(setwd(wd ))
123108 expect_warning(md <- codebook(bfi3 ))
124109 figs <- list.files(paste0(dir , " /figure" ))
125- expect_equal(length(figs ), 8 )
110+ expect_equal(length(figs ), 7 )
126111 expect_match(md , " Scale: BFIK_neuro" )
127112 expect_match(md , " Missings per variable" )
128113 expect_match(md , " 168 completed rows" )
129114
130115 unlink(paste0(dir , " /figure" ), recursive = TRUE )
131116})
117+
118+
119+
120+ test_that(" codebook generation via helper fun" , {
121+ data(" bfi" , package = ' codebook' )
122+ library(dplyr )
123+ bfi <- bfi %> % select(- starts_with(" BFIK_extra" ),
124+ - starts_with(" BFIK_agree" ),
125+ - starts_with(" BFIK_open" ))
126+ bfi $ age <- 1 : nrow(bfi )
127+ wd <- getwd()
128+ dir <- tempdir()
129+ setwd(dir )
130+ on.exit(setwd(wd ))
131+ saveRDS(bfi , " bfi.rds" )
132+ expect_message(md <- load_data_and_render_codebook(" bfi.rds" ,
133+ "
134+ ```{r}
135+ codebook(codebook_data)
136+ ```
137+ " ))
138+ })
0 commit comments