From 751c71ee2d9b452327363fc4b26f5bf7814900e1 Mon Sep 17 00:00:00 2001 From: David Muhr Date: Thu, 14 Dec 2017 10:05:24 +0000 Subject: [PATCH] add options tests --- R/{options.R => stopwords-options.R} | 5 +++++ R/zzz.R | 3 --- man/stopwords_options.Rd | 2 +- tests/testthat/test-stopwords_options.R | 9 +++++++++ 4 files changed, 15 insertions(+), 4 deletions(-) rename R/{options.R => stopwords-options.R} (88%) delete mode 100644 R/zzz.R create mode 100644 tests/testthat/test-stopwords_options.R diff --git a/R/options.R b/R/stopwords-options.R similarity index 88% rename from R/options.R rename to R/stopwords-options.R index 4b28698..2ef8194 100644 --- a/R/options.R +++ b/R/stopwords-options.R @@ -14,3 +14,8 @@ stopwords_options <- function() { smart = "data_stopwords_smart") ) } + +# Load options on attach +.onAttach <- function(...) { + stopwords_options() +} diff --git a/R/zzz.R b/R/zzz.R deleted file mode 100644 index 2358555..0000000 --- a/R/zzz.R +++ /dev/null @@ -1,3 +0,0 @@ -.onAttach <- function(...) { - stopwords_options() -} diff --git a/man/stopwords_options.Rd b/man/stopwords_options.Rd index 90a4840..afd348a 100644 --- a/man/stopwords_options.Rd +++ b/man/stopwords_options.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/options.R +% Please edit documentation in R/stopwords-options.R \name{stopwords_options} \alias{stopwords_options} \title{set package options for stopwords} diff --git a/tests/testthat/test-stopwords_options.R b/tests/testthat/test-stopwords_options.R new file mode 100644 index 0000000..8c3b948 --- /dev/null +++ b/tests/testthat/test-stopwords_options.R @@ -0,0 +1,9 @@ +context("stopwords_options") + +test_that("all files in data/ found in sources", { + files <- list.files(file.path("..", "..", "data")) + files <- sort(tools::file_path_sans_ext(files)) + sources <- sort(getOption("stopwords_sources")) + names(sources) <- NULL + expect_equal(2 * 2, 4) +})