Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul vcr_configure() to avoid overwriting existing config parameters #141

Merged
merged 21 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Description: Record test suite 'HTTP' requests and replays them during
real 'HTTP' responses on disk in 'cassettes'. Subsequent 'HTTP' requests
matching any previous requests in the same 'cassette' use a cached
'HTTP' response.
Version: 0.4.1.93
Version: 0.4.1.94
Authors@R: c(person("Scott", "Chamberlain", role = c("aut", "cre"),
email = "sckott@protonmail.com",
comment = c(ORCID="0000-0003-1444-9135")),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ importFrom(lazyeval,lazy_dots)
importFrom(lazyeval,lazy_eval)
importFrom(urltools,url_compose)
importFrom(urltools,url_parse)
importFrom(utils,getParseData)
importFrom(webmockr,pluck_body)
importFrom(yaml,as.yaml)
importFrom(yaml,yaml.load)
Expand Down
22 changes: 2 additions & 20 deletions R/cassette_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,32 +132,14 @@ Cassette <- R6::R6Class(
self$serialize_with <- serialize_with
self$persist_with <- persist_with
if (!missing(record)) {
recmodes <- c("none", "once", "new_episodes", "all")
if (!record %in% recmodes) {
stop("'record' value of '", record, "' is not in the allowed set: ",
paste0(recmodes, collapse = ", "), call. = FALSE)
}
self$record <- record
self$record <- check_record_mode(record)
}
self$make_dir()
self$manfile <- sprintf("%s/%s.yml", path.expand(cassette_path()),
self$name)
if (!file.exists(self$manfile)) cat("\n", file = self$manfile)
if (!missing(match_requests_on)) {
mro <- c("method", "uri", "headers", "host", "path", "body")
if (!any(match_requests_on %in% mro)) {
stop("1 or more 'match_requests_on' values (",
paste0(match_requests_on, collapse = ", "),
") is not in the allowed set: ",
paste0(mro, collapse = ", "), call. = FALSE)
}
# we don't yet support the following matchers: host, path
if (any(match_requests_on %in% c("host", "path"))) {
stop("we do not yet support host and path matchers",
"\n see https://github.com/ropensci/vcr/issues/70",
call. = FALSE)
}
self$match_requests_on <- match_requests_on
self$match_requests_on <- check_request_matchers(match_requests_on)
}
if (!missing(re_record_interval))
self$re_record_interval <- re_record_interval
Expand Down
2 changes: 1 addition & 1 deletion R/cassettes.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#'
#' # list the path to cassettes
#' cassette_path()
#' vcr_configure(file.path(tempdir(), "foo"))
#' vcr_configure(dir = file.path(tempdir(), "foo"))
#' cassette_path()
#'
#' vcr_configure_reset()
Expand Down
2 changes: 1 addition & 1 deletion R/check_cassette_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ check_cassette_names <- function(pattern = "test-", behavior = "stop") {
if (length(files) == 0) return()
cassette_names <- function(x) {
tmp <- parse(x, keep.source = TRUE)
df <- getParseData(tmp)
df <- utils::getParseData(tmp)
row.names(df) = NULL
z <- as.numeric(row.names(df[df$text == "use_cassette", ])) + 2
gsub("\"", "", df[z, "text"])
Expand Down
Loading