Skip to content

Commit 0743364

Browse files
committed
#220 fix for this issue in webmockr - but a fix needed here for the change in webmockr
- RequestMatcherRegistry register_$built_ins method needed fix in the rul for path: strip trailing slash first
1 parent ab847dd commit 0743364

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ LinkingTo:
3232
Imports:
3333
crul (>= 0.8.4),
3434
httr,
35-
webmockr (>= 0.7.4),
35+
webmockr (>= 0.7.4.93),
3636
urltools,
3737
yaml,
3838
R6,
@@ -48,6 +48,7 @@ Suggests:
4848
cli,
4949
curl,
5050
withr
51+
Remotes: ropensci/webmockr
5152
X-schema.org-applicationCategory: Web
5253
X-schema.org-keywords: http, https, API, web-services, curl, mock, mocking, http-mocking, testing, testing-tools, tdd
5354
X-schema.org-isPartOf: https://ropensci.org

R/request_matcher_registry.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ RequestMatcherRegistry <- R6::R6Class(
4949
self$register("body", function(r1, r2) identical(r1$body, r2$body))
5050
self$register('headers', function(r1, r2) identical(r1$headers, r2$headers))
5151
self$register("host", function(r1, r2) identical(r1$host, r2$host))
52-
self$register("path", function(r1, r2) identical(r1$path, r2$path))
52+
self$register("path", function(r1, r2)
53+
identical(sub("/$", "", r1$path), sub("/$", "", r2$path)))
5354
self$register("query", function(r1, r2) identical(r1$query, r2$query))
5455
self$try_to_register_body_as_json()
5556
},

tests/testthat/test-RequestMatcherRegistry.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ test_that("RequestMatcherRegistry basic functionality works", {
7575
expect_false(request_matchers$registry$path$matches(b, d))
7676
expect_true(request_matchers$registry$path$matches(c, d))
7777
expect_true(request_matchers$registry$path$matches(b, e))
78+
## trailing slash is removed
79+
expect_true(request_matchers$registry$path$matches(
80+
list(path="foo"), list(path="foo/")))
7881

7982
# query
8083
expect_true(request_matchers$registry$body_as_json$matches(a, b))

0 commit comments

Comments
 (0)