Skip to content
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

URLRequest.ohhttpStubs_HTTPBody() method not found #259

Closed
6 of 9 tasks
mplorentz opened this issue Sep 28, 2017 · 4 comments
Closed
6 of 9 tasks

URLRequest.ohhttpStubs_HTTPBody() method not found #259

mplorentz opened this issue Sep 28, 2017 · 4 comments

Comments

@mplorentz
Copy link
Collaborator

New Issue Checklist

Environment

  • version of OHHTTPStubs: 6.0.0
  • integration method you are using:
    • Cocoapods
    • Carthage
    • submodule
    • other
  • version of the tool you use: 1.3.1

Issue Description

I am having trouble using the ohhttpStubs_HTTPBody() method on URLRequest. When I try to use it I get a compilation error: "Value of type 'URLRequest' has no member 'ohhttpStubs_HTTPBody'".

I am running Xcode 9.0 (9A235) and building a Swift 4 project. I have uploaded a sample project that exhibits the issue.
ohhttpstubstest.zip

It looks like this was an issue in Swift 3 (#222) and version 6.0.0 was supposed to fix this issue.

The workaround given in #22 (request as NSURLRequest).ohhttpStubs_HTTPBody() does work for me, but I figured I would open a ticket since this is supposed to be fixed.

Complete output when you encounter the issue (if any)
Value of type 'URLRequest' has no member 'ohhttpStubs_HTTPBody'
@AliSoftware
Copy link
Owner

Hey @mplorentz, thanks for reporting the issue!

I believe you're right, I might have closed #222 too soon.
The big change which made me close #222 was that now the subspec OHHTTPStubs/Swift always includes other subspecs necessary to make it work for all configuration. But in fact #222 only makes it now possible to implement that now, but I haven't indeed exposed it entirely yet.

So since #222, I've added the hasBody matcher, so that you can now stub(isHost("my-host.com") && hasBody(myBodyData)) { req in … } — and this hasBody matcher is only possible thanks to #222 — but to access ohhttpStubs_HTTPBody() on URLRequest I indeed haven't exposed it to Swift in a nicer way than still forcing you to cast to NSURLRequest first.

I'll try to do a fix soon (probably re-applying parts of #216 — but without the #if OHHTTPSTUBS_NSURLSESSION_HTTPBODY lines which were not working as expected anyway)

@mplorentz
Copy link
Collaborator Author

I can take a shot at it. #216 looks easy enough to reimplement. I will try to submit a PR tomorrow.

@AliSoftware
Copy link
Owner

Cool, looking forward to it!
(Don't forget to credit yourself in the CHANGELOG too!)

@AliSoftware
Copy link
Owner

@mplorentz just gave you push access to the repo so you can create your branch directly on it instead of having to fork 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants