tests/testthat/helper-rcol.R

library("vcr")
vcr::vcr_configure(dir = "../fixtures", serialize_with = "json")

has_internet <- function() {
  z <- try(suppressWarnings(readLines('https://www.google.com', n = 1)), 
    silent = TRUE)
  !inherits(z, "try-error")
}

skip_if_net_down <- function() {
  if (has_internet()) {
    return()
  }
  testthat::skip("no internet")
}
ropensci/rcol documentation built on Sept. 12, 2022, 8:08 a.m.