Skip to content

Commit

Permalink
fixed test in gbif_parse, output characters, not factors in the df
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Sep 23, 2015
1 parent 8234ed8 commit c0c4175
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion R/gbif_parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ gbif_parse <- function(scientificname) {
body = jsonlite::toJSON(scientificname))
stop_for_status(tt)
res <- content(tt)
tmp <- do.call(rbind.fill, lapply(res, as.data.frame))
tmp <- do.call(rbind.fill, lapply(res, as.data.frame, stringsAsFactors = FALSE))
setNames(tmp, tolower(names(tmp)))
}
11 changes: 5 additions & 6 deletions tests/testthat/test-gbif_parse.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
# tests for gbif_parse fxn in taxize
context("gbif_parse")

tt <- gbif_parse(scientificname='x Agropogon littoralis')
tt <- gbif_parse(scientificname = 'x Agropogon littoralis')

test_that("gbif_parse returns the correct value", {
expect_that(as.character(tt[1,1]), matches('x Agropogon littoralis'))
expect_that(as.character(tt[1,2]), matches('SCINAME'))
expect_that(as.character(tt[1,2]), matches('SCIENTIFIC'))
})

test_that("gbif_parse returns the correct dimensions", {
expect_that(dim(tt), equals(c(1,9)))
})

test_that("gbif_parse returns the correct class", {
expect_that(tt, is_a("data.frame"))
expect_that(tt$specificepithet, is_a("factor"))
expect_that(tt$authorsparsed, is_a("logical"))
expect_is(tt, "data.frame")
expect_is(tt$specificepithet, "character")
expect_is(tt$authorsparsed, "logical")
})

0 comments on commit c0c4175

Please sign in to comment.