Skip to content

Commit

Permalink
Add unit test to make sure austen_books() has right factor levels
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasilge committed Oct 23, 2016
1 parent 6bd90d0 commit 3f12439
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(janeaustenr)

test_check("janeaustenr")
15 changes: 15 additions & 0 deletions tests/testthat/test_austen_books.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# tests for austen_books function

context("Tidy dataframe for books")

suppressPackageStartupMessages(library(dplyr))

test_that("tidy frame for Austen books is right", {
d <- austen_books() %>%
group_by(book) %>%
summarise(total_lines = n())
expect_equal(nrow(d), 6)
expect_equal(ncol(d), 2)
expect_equal(as.character(d$book[1]), "Sense & Sensibility")
expect_equal(as.character(d$book[6]), "Persuasion")
})

0 comments on commit 3f12439

Please sign in to comment.