tests/testthat/helper-webmockr.R

sm <- function(x) suppressMessages(x)

get_err_mssg <- function(x) {
  tmp <- tryCatch(x, error = function(e) e)
  if (inherits(tmp, "error")) unclass(tmp)$message else tmp
}

# from https://stackoverflow.com/a/14838321/1091766
re_escape <- function(strings){
  vals <- c("\\\\", "\\[", "\\]", "\\(", "\\)",
            "\\{", "\\}", "\\^", "\\$","\\*",
            "\\+", "\\?", "\\.", "\\|")
  replace.vals <- paste0("\\\\", vals)
  for(i in seq_along(vals)){
    strings <- gsub(vals[i], replace.vals[i], strings)
  }
  strings
}

Try the webmockr package in your browser

Any scripts or data that you put into this service are public.

webmockr documentation built on March 7, 2023, 5:25 p.m.