Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Oct 6, 2024
2 parents 2ca74d9 + acac4b4 commit b3e362b
Show file tree
Hide file tree
Showing 103 changed files with 2,738 additions and 903 deletions.
5 changes: 4 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
^\.Rproj\.user$
man-roxygen/
^README.Rmd$
^README.md$
^\.travis.yml$
^CODE_OF_CONDUCT\.md$
Makefile
notes.md
notes.R
.github
cran-comments.md
^codemeta\.json$
revdep/
^revdep$
appveyor.yml
^docs$
write_disk_path-changes.R
details.*
^_pkgdown.yml$
^LICENSE\.md$
50 changes: 18 additions & 32 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,40 @@ jobs:
fail-fast: false
matrix:
config:
- { os: windows-latest, r: 'latest'}
- { os: macOS-latest, r: 'latest'}
- { os: macOS-latest, r: 'devel'}
- { os: ubuntu-16.04, r: '3.5', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
- { os: ubuntu-16.04, r: 'latest', cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"}
- { os: windows-latest, r: 'release'}
- { os: windows-latest, r: 'devel'}
- { os: ubuntu-latest, r: 'release'}
- { os: ubuntu-latest, r: 'devel'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
CRAN: ${{ matrix.config.cran }}

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@master
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-pandoc@master
- uses: r-lib/actions/setup-pandoc@v2

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-${{ matrix.config.r }}-${{ hashFiles('DESCRIPTION') }}
extra-packages: any::rcmdcheck
needs: check

- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
- name: Session info
run: |
Rscript -e "install.packages('remotes')" -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install dependencies
run: Rscript -e "install.packages('remotes')" -e "remotes::install_deps(dependencies = TRUE)" -e "remotes::install_cran('rcmdcheck')"
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

- name: Check
run: Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'warning', check_dir = 'check')"

- name: Upload check results
if: failure()
uses: actions/upload-artifact@master
- uses: r-lib/actions/check-r-package@v2
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
upload-snapshots: true

- name: Test coverage
if: matrix.config.os == 'macOS-latest' && matrix.config.r == 'latest'
if: matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release'
run: |
Rscript -e 'install.packages("covr")' -e 'covr::codecov(token = "${{secrets.CODECOV_TOKEN}}")'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
.Rhistory
.RData
notes.md
notes.R
.DS_Store
revdep/checks.noindex
revdep/data.sqlite
revdep/library.noindex
write_disk_path-changes.R
^docs$
notes.R
16 changes: 9 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Description: Stubbing and setting expectations on 'HTTP' requests.
'HTTP' method, query parameters, request body, headers and
more. Can be used for unit tests or outside of a testing
context.
Version: 0.6.4.91
Version: 1.0.0.91
Authors@R: c(
person("Scott", "Chamberlain", role = c("aut", "cre"), email =
"myrmecocystus+r@gmail.com", comment = c(ORCID="0000-0003-1444-9135")),
Expand All @@ -15,10 +15,10 @@ Authors@R: c(
person("rOpenSci", role = "fnd", comment = "https://ropensci.org")
)
License: MIT + file LICENSE
URL: https://github.com/ropensci/webmockr (devel),
https://books.ropensci.org/http-testing (user manual)
URL: https://github.com/ropensci/webmockr,
https://books.ropensci.org/http-testing/,
https://docs.ropensci.org/webmockr/
BugReports: https://github.com/ropensci/webmockr/issues
LazyData: true
Encoding: UTF-8
Language: en-US
Roxygen: list(markdown = TRUE)
Expand All @@ -29,13 +29,15 @@ Imports:
R6 (>= 2.1.3),
urltools (>= 1.6.0),
fauxpas,
crul (>= 0.7.0)
crul (>= 0.7.0),
base64enc
Suggests:
testthat,
xml2,
vcr,
httr
RoxygenNote: 7.1.1
httr,
httr2
RoxygenNote: 7.3.2
X-schema.org-applicationCategory: Web
X-schema.org-keywords: http, https, API, web-services, curl, mock, mocking, fakeweb, http-mocking, testing, testing-tools, tdd
X-schema.org-isPartOf: https://ropensci.org
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2020
YEAR: 2022
COPYRIGHT HOLDER: Scott Chamberlain
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2022 Scott Chamberlain

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ doc:
${RSCRIPT} -e "devtools::document()"

eg:
${RSCRIPT} -e "devtools::run_examples(run = TRUE)"
${RSCRIPT} -e "devtools::run_examples(run_dontrun = TRUE)"

test:
${RSCRIPT} -e "devtools::test()"
Expand Down
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,28 @@ export(CrulAdapter)
export(HashCounter)
export(HeadersPattern)
export(HttpLibAdapaterRegistry)
export(Httr2Adapter)
export(HttrAdapter)
export(MethodPattern)
export(RequestPattern)
export(RequestRegistry)
export(RequestSignature)
export(Response)
export(StubCounter)
export(StubRegistry)
export(StubbedRequest)
export(UriPattern)
export(build_crul_request)
export(build_crul_response)
export(build_httr2_request)
export(build_httr2_response)
export(build_httr_request)
export(build_httr_response)
export(disable)
export(enable)
export(enabled)
export(excluding)
export(httr2_mock)
export(httr_mock)
export(including)
export(mock_file)
Expand Down Expand Up @@ -53,6 +58,7 @@ export(webmockr_reset)
export(wi_th)
export(wi_th_)
importFrom(R6,R6Class)
importFrom(base64enc,base64encode)
importFrom(crul,mock)
importFrom(fauxpas,HTTPRequestTimeout)
importFrom(magrittr,"%>%")
82 changes: 82 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,85 @@
webmockr 1.0.0
==============

### NEW FEATURES

* `webmockr` now supports the `httr2` library, in addition to `httr` and `crul`. Note that you'll see different behavior from `httr2` relative to the other 2 http clients because it turns http errors (http statuses 400 and above) into R errors (#122)
* `webmockr` can now mock async http requests with `crul` (w/ `crul` v1.5 or greater). no change was required in `webmockr` for this to happen. a PR was merged in `crul` to hook into `webmockr`. there's no support for async in `httr` as that package does not do any async and no support in `httr2` because `req_perform_parallel` does not have a mocking hook as does `req_perform` (#124)


webmockr 0.9.0
==============

### BUG FIXES

* `to_return()` supports returning multiple responses to match many requests to the same matching stub. however, the internals were broken for this, but is now fixed (#115) thanks @kenahoo for the report
* matching stubs with specifying a request body to match on (e.g., `stub_request('post', 'https://httpbin.org/post') %>% wi_th(body = list(a=5))`) was not working in some cases; internal matching logic was borked. now fixed. (#118) thanks @konradoberwimmer for the report
* The `status` parameter in `to_return()` was documented to accept an integer, but it errored when an integer was passed (e.g., `to_return(status=200L)`). This bug is now fixed (#117) thanks @maelle for the report

### MINOR IMPROVEMENTS

* Config options changes (see `webmockr_configure()`). Three options that were presentg but not implemented are now removed: `show_body_diff`, ` query_values_notation`, ` net_http_connect_on_start`. One option that was present but not implemented yet is now implemented: ` show_stubbing_instructions` (#27) (#120)

### DOCUMENTATION

* `StubCounter` added to pkgdown docs page at <https://docs.ropensci.org/webmockr/reference/StubCounter.html> (#119) @maelle


webmockr 0.8.2
==============

### BUG FIXES

* change to `UriPattern` to make sure regex matching is working as intended (#114) thanks @kenahoo


webmockr 0.8.0
==============

### NEW FEATURES

* `enable()` and the `enable()` method on the `Adapter` R6 class gain new parameter `quiet` to toggle whether messages are printed or not (#112)

### MINOR IMPROVEMENTS

* to re-create http response objects for both httr and crul we were using the url from the request object; now we use the url from the response object, BUT if there is no url in the response object we fall back to using the url from the request object (#110) (#113)
* improve docs: add further explanation to manual files for both `to_raise()` and `to_return()` to explain the differenc between them and when you may want to use them (#100)


webmockr 0.7.4
==============

### MINOR IMPROVEMENTS

* to support vcr being able to recreate httr objects fully (see github issue ropensci/vcr#132) we needed to handle additional parts of httr request objects: fields and output - with this change vcr should return objects much closer to what real httr requests return (#109)

### BUG FIXES

* bug fix + improvement: fixes for simple authentication - `wi_th()` now supports `basic_auth` to mock basic authentication either with `crul::auth()` or `httr::authenticate()` (#108)


webmockr 0.7.0
==============

### NEW FEATURES

* Gains ability to define more than 1 returned HTTP response, and the order in which the HTTP responses are returned. The idea is from the Ruby webmock library, but the implementation is different because the Ruby and R languages are very different. You can give more than one `to_return()` one creating a stub, or if you want to return the same response each time, you can use the new `times` parameter within `to_return()`. As a related use case (#31) you can mock http retry's using this new feature (#10) (#32) (#101)
* Gains new function `webmockr_reset()` to be able to reset stub registry and request registry in one function call (#97) (#101)
* Gains support for mocking simple authentication. `wi_th()` now accepts `basic_auth` in addition to query, body, and headers. Note that authentication type is ignored (#103)

### MINOR IMPROVEMENTS

* change to how URI's are matched in `stub_request()`: we weren't allowing matching URI's without schemes; you can now do that. In addition, webmockr can match URI's without the "http" scheme, but does not match if the scheme is "https". See `UriPattern` for more (#102)
* another change to how URI's are matched: now query params compared separately to the URI; note that regex not allowed in query params (#104) - And now query parameters are compared with the same code both when regex uri is used and when it is not (#107)
* URI matching for stubs is now done only on the URI's themselves; that is, query parameters are removed before comparison, so only the base url with http scheme, plus paths, are compared (#107)
* wasn't sure `write_disk_path` behavior was correct when using httr, seems to be working, added tests for it (#79)
* values for query parameters given to `wi_th()` are now all coerced to character class to make sure that all comparisons of stubs and requests are done with the same class (character) (#107)

### BUG FIXES

* fix for `uri_regex` usage in `stub_request()`: no longer curl escape the `uri_regex` given, only escape a non-regex uri (#106)


webmockr 0.6.2
==============

Expand Down
2 changes: 1 addition & 1 deletion R/HttpLibAdapterRegistry.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ HttpLibAdapaterRegistry <- R6::R6Class(
#' @return nothing, registers the library adapter
register = function(x) {
# FIXME: when other adapters supported, change this inherits test
if (!inherits(x, c("CrulAdapter", "HttrAdapter"))) {
if (!inherits(x, c("CrulAdapter", "HttrAdapter", "Httr2Adapter"))) {
stop("'x' must be an adapter, such as CrulAdapter", call. = FALSE)
}
self$adapters <- c(self$adapters, x)
Expand Down
Loading

0 comments on commit b3e362b

Please sign in to comment.