diff --git a/DESCRIPTION b/DESCRIPTION index fd2eb5e..a5d131c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: boxr Type: Package Title: Interface for the 'Box.com API' -Version: 0.3.6.9006 +Version: 0.3.6.9007 Authors@R: c( person("Brendan", "Rocks", email = "foss@brendanrocks.com", role = c("aut")), diff --git a/NEWS.md b/NEWS.md index 1530d2a..8aa1082 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,15 @@ # boxr 0.3.6 (development) +## Fixes + +* fix bug in `box_save()`, setting default environment for evaluating dots (#255) + ## Internal * refactor to use withr functions to handle temp files. (#183) +* activate tests for `box_save()`, `box_load()` (#255) + * update documentation to reflect updates to rio package. (#242, @chainsawriot) * update maintainer's email address. (#248) diff --git a/R/boxr_save_load.R b/R/boxr_save_load.R index 06fde60..f9b781b 100644 --- a/R/boxr_save_load.R +++ b/R/boxr_save_load.R @@ -33,7 +33,7 @@ box_save <- function(..., dir_id = box_getwd(), file_name = ".RData", temp_file <- withr::local_tempfile(pattern = file_name) - save(..., file = temp_file) + save(..., envir = parent.frame(), file = temp_file) box_ul(dir_id, temp_file, description = description) } diff --git a/tests/testthat/test_04_load_save.R b/tests/testthat/test_04_load_save.R index d90dd10..729adce 100644 --- a/tests/testthat/test_04_load_save.R +++ b/tests/testthat/test_04_load_save.R @@ -1,44 +1,27 @@ -# Load/Save --------------------------------------------------------------- -# For some reason (probably related to environements), these run fine in the -# console/terminal, but testthat can't find the files when running them with -# devtools::test() -# -# Leaving not-run, for now -if (FALSE) { - context("Load/Save") - - test_that("Saving R Object Remotely", { - skip_on_cran() - skip_if_no_token() - - # Here's an R object - test_list <- list(data.frame(), 1:10, letters) - test_vars$test_list <- test_list - rda_name <- "test.RData" - - # The upload should throw an error if it doesn't work - b <- box_save(test_list, envir = globalenv(), dir_id = 0, file_name = rda_name) - - # Put the id in an environment variable for subsequent tests - test_vars$object_return <- b - - # Did the file end up with the right name? - expect_equal(rda_name, b$entries[[1]]$name) - }) - - test_that("Loading remote R object", { - skip_on_cran() - skip_if_no_token() - - rm("object") - - # Can you load the remote file which stores the R object? - b <- box_load(test_vars$object_return$entries[[1]]$id) - - # Did it return the right object name? - expect_equal("object", b) - # Is the R object the same after it's journey? - expect_equal(object, test_vars$object) - }) - -} +context("Load/Save") + +test_that("object can be saved, retrieved, and deleted", { + skip_on_cran() + skip_if_no_token() + + # Here's an R object + test_ref <- list(data.frame(), 1:10, letters) + + test_list <- test_ref + rda_name <- "test.RData" + + b_save <- box_save(test_list, dir_id = 0, file_name = rda_name) + expect_equal(rda_name, b_save$name) + + rm("test_list") + + # will load data into `test_list` + b_load <- box_load(b_save$id) + expect_identical(b_load, "test_list") + expect_equal(test_ref, test_list) + + # clean up + box_delete_file(b_save$id) + +}) +