-
Notifications
You must be signed in to change notification settings - Fork 179
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
Matcher doesn't match partly URLs #96
Comments
That is intentional, it is designed to be the full URI of full path. Try the following: func isLogin(_ request: URLRequest) -> Bool {
return request.url?.path.hasSuffix("/auth/login") ?? false
}
stub(isLogin, failure(error)) |
thx. your suggested solution works, but not very intuitive on first sight. can you please elaborate more on the design decision of only matching full URIs instead of only partly matching? |
I also noticed that it really needs to match the full URI including query parameters, which is very cumbersome in my case. The requests I want to simply mock have lots of query parameters. My use case: So my workaround is creating this new matcher to partly match the uri
and then
I believe a mocking library should offer a built-in possibility to mock network requests in a very easy and very fast way. This includes only matching part of uri. eg. instead of using the regex pattern |
It seems current version (2.0.1) of matcher doesn't match uri path partly.
Example:
This test will fail. It seems I always need to specify everything after the host in the uri matcher. This is a bit inconvenient.
Because eg. I as mobile app developer don't want to care how the backend has structured the login endpoint in my tests or which endpoint version it is. I'm only interested in stubbing the login request.
Or did I miss something?
The text was updated successfully, but these errors were encountered: