Skip to content

Commit

Permalink
#220 fix for this issue in webmockr - but a fix needed here for the c…
Browse files Browse the repository at this point in the history
…hange in webmockr

- RequestMatcherRegistry register_$built_ins method needed fix in the rul for path: strip trailing slash first
  • Loading branch information
sckott committed Jan 29, 2021
1 parent ab847dd commit 0743364
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ LinkingTo:
Imports:
crul (>= 0.8.4),
httr,
webmockr (>= 0.7.4),
webmockr (>= 0.7.4.93),
urltools,
yaml,
R6,
Expand All @@ -48,6 +48,7 @@ Suggests:
cli,
curl,
withr
Remotes: ropensci/webmockr
X-schema.org-applicationCategory: Web
X-schema.org-keywords: http, https, API, web-services, curl, mock, mocking, http-mocking, testing, testing-tools, tdd
X-schema.org-isPartOf: https://ropensci.org
Expand Down
3 changes: 2 additions & 1 deletion R/request_matcher_registry.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ RequestMatcherRegistry <- R6::R6Class(
self$register("body", function(r1, r2) identical(r1$body, r2$body))
self$register('headers', function(r1, r2) identical(r1$headers, r2$headers))
self$register("host", function(r1, r2) identical(r1$host, r2$host))
self$register("path", function(r1, r2) identical(r1$path, r2$path))
self$register("path", function(r1, r2)
identical(sub("/$", "", r1$path), sub("/$", "", r2$path)))
self$register("query", function(r1, r2) identical(r1$query, r2$query))
self$try_to_register_body_as_json()
},
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-RequestMatcherRegistry.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ test_that("RequestMatcherRegistry basic functionality works", {
expect_false(request_matchers$registry$path$matches(b, d))
expect_true(request_matchers$registry$path$matches(c, d))
expect_true(request_matchers$registry$path$matches(b, e))
## trailing slash is removed
expect_true(request_matchers$registry$path$matches(
list(path="foo"), list(path="foo/")))

# query
expect_true(request_matchers$registry$body_as_json$matches(a, b))
Expand Down

0 comments on commit 0743364

Please sign in to comment.