Skip to content

Commit

Permalink
Actual test for onLoad
Browse files Browse the repository at this point in the history
  • Loading branch information
nfultz committed Feb 9, 2018
1 parent c05012d commit ee2d9b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tests/testthat/test-texreg.R
Expand Up @@ -3,21 +3,19 @@
context("S3 - texreg builds")

test_that("texreg extension works", {
skip_if_not_installed("texreg")
library(texreg)

model2 <- lm_robust(extra~group, sleep, clusters = "ID")

library(texreg)

capture.output(treg <- extract(model2, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE))
expect_is(
treg,
"texreg"
)

# juicin the stats
expect_error(
.onLoad("lm_robust", "lm_robust"),
NA
)

})


14 changes: 14 additions & 0 deletions tests/testthat/test-zzz.R
@@ -0,0 +1,14 @@
context("zzz.R - .onLoad")

test_that("onLoad makes generics if texreg is present", {
skip_if_not_installed("texreg")

e <- environment(.onLoad)

environment(.onLoad) <- new.env(parent=parent.env(e))
environment(.onLoad)$extract.lm_robust <- e$extract.lm_robust

expect_null(.onLoad("estimatr", "estimatr"))
environment(.onLoad) <- e

})

0 comments on commit ee2d9b9

Please sign in to comment.