Skip to content

Commit

Permalink
update tests to handle kable output
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Marwick committed May 27, 2017
1 parent 2324dfc commit db4f940
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Imports:
dplyr,
purrr,
shiny,
stringr
stringr,
knitr
Suggests:
testthat,
covr
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export(run_grammar_checker)
export(write_good_file)
export(write_good_ip)
import(V8)
import(knitr)
import(shiny)
importFrom(dplyr,data_frame)
importFrom(purrr,map)
Expand Down
4 changes: 2 additions & 2 deletions R/check_grammar.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ write_good_ip <- function(){
#' @return a print out of suggestions for grammar fixes
#' @export

#' @import V8
#' @import V8 knitr
#' @examples
#' # don't run during tests
#' # write_good_file()
Expand All @@ -73,7 +73,7 @@ write_good_file <- function(filename = ""){
# load write-good
ct <- init_write_good()
# analyse the text
write_good_output <- ct$call("writeGood", untitled_text)
write_good_output <- ct$call("writeGood", file_text)
write_good_output_tidy <- kable(write_good_output)
if(is.null(nrow(write_good_output))) {
message("write-good found no problems. Your writing is good!")
Expand Down
10 changes: 6 additions & 4 deletions man/run_grammar_checker.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions tests/testthat/test_write_good_ip.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ context("write-good check of simple Rmd file")
write_good_check_of_Rmd_file <- write_good_file("test.Rmd")

test_that("it works on an Rmd file", {
expect_equal(nrow(write_good_check_of_Rmd_file), 2)
expect_equal(ncol(write_good_check_of_Rmd_file), 3)
expect_is(write_good_check_of_Rmd_file, "knitr_kable")
})

context("write-good check of complex Rmd file")

write_good_check_of_Rmd_file_with_multiple_lines <- write_good_file("test_multiple_lines.Rmd")

test_that("it works on an Rmd file with multiple lines", {
expect_equal(nrow(write_good_check_of_Rmd_file_with_multiple_lines), 2)
expect_equal(ncol(write_good_check_of_Rmd_file_with_multiple_lines), 3)
expect_is(write_good_check_of_Rmd_file_with_multiple_lines, "knitr_kable")
})

0 comments on commit db4f940

Please sign in to comment.