-
Notifications
You must be signed in to change notification settings - Fork 12
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
Record json-encoded bodies #130
Conversation
thanks - and glad to see more usage! First to address the I think it makes sense to export |
Totally agree. Will update the PRs accordingly. |
thanks |
Needed to satisfy webmockr::pluck_body()'s assertions
Still working on this... Currently the following test fails out4 <- use_cassette("httr_post_upload_file", {
b <- POST("https://httpbin.org/post",
body = list(y = httr::upload_file(system.file("CITATION"))))
})
...
expect_match(strj$data, "bibentry\\(") because |
I think i got webmockr and vcr working locally - for vcr: add and in webmockr in RequestSignature: in the print method, replace
and replace the to_string <- function(x) {
if (inherits(x, "list") && all(nchar(names(x)) > 0)) {
tmp <- paste0(paste(names(x), x, sep = ": "), collapse = ", ")
} else if (inherits(x, "list") && any(nchar(names(x)) == 0)) {
tmp <- paste0(paste(names(x), x, sep = ": "), collapse = ", ")
} else if (inherits(x, "form_file")) {
tmp <- sprintf("type=%s; path=%s", x$type, x$path)
} else {
tmp <- paste0(x, collapse = ", ")
}
return(sprintf("{%s}", tmp))
} With those changes, everything works locally for me, thoughts? |
I'll check it out! Should I apply these patches to the respective master branches or on top of the current PRs? |
In the current prs
…On Thu, Dec 19, 2019 at 08:14 Aaron Wolen ***@***.***> wrote:
I'll check it out!
Should I apply these patches to the respective master branches or on top
of the current PRs?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#130?email_source=notifications&email_token=AAENBBACAIKWGEJ64JIEIDDQZOMWJA5CNFSM4J2WPX22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHKDP3Q#issuecomment-567556078>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAENBBDHAPL5ZM2JI2XEKWDQZOMWJANCNFSM4J2WPX2Q>
.
|
Looks like that did the trick! 🎉 Of course we're being robbed of the satisfaction of passing tests because the minimum required version of webmockr is now 0.5.1.92 but I verified everything checks out in a fresh docker container. |
thanks for all your work on this! |
Apologies for the barrage PRs, I'm working on adding mocked-tests to osfr 🙂.
This is related to the issue addressed in webmockr PR#82, which prevented json-encoded bodies from being recorded to cassettes.
I added a new test file that basically mirrors
tests/testthat/test-ause_cassette_match_requests_on.R
albeit with JSON encoded requests. This might be overkill.It'd be nice to have an exported version of
pluck_body()
somewhere that could be used in both packages but I'm not sure where that should go...Let me know if you have any questions/suggestions.