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

Find Swift 2-compatible HTTP request mocking library #46

Closed
czechboy0 opened this issue Jun 27, 2015 · 20 comments
Closed

Find Swift 2-compatible HTTP request mocking library #46

czechboy0 opened this issue Jun 27, 2015 · 20 comments

Comments

@czechboy0
Copy link
Member

I'd like to add proper tests for requests/responses, so we need a library that helps us with that. I tried Mockingjay, unfortunately it doesn't yet have Swift 2 support. This is pretty urgent.

(cc: @cojoj and @esttorhe)

@esttorhe
Copy link
Member

We could use OHHTTPStubs or VCR (can't remember the correct name; as soon as I remember I'll update it here)

@cojoj
Copy link
Contributor

cojoj commented Jun 27, 2015

Well whet it comes to mocking I've recently read this cool article. But yes I agree that we need some solution to test this.

@esttorhe
Copy link
Member

ahhhh; thanks @cojoj, DVR was the one I was thinking about; that's the one that Orta uses at Artsy; I wrote one called Rec but is not working correctly on Swift 2.0 and that's why I'm not suggesting that one :p

@cojoj
Copy link
Contributor

cojoj commented Jun 27, 2015

Well, I've heard a lot of good about OHHTTPStubs but Objective-C - it hurts, lika a lot! 😜

@czechboy0
Copy link
Member Author

I like the approach mentioned in the article. Let me take a 👀.

@esttorhe
Copy link
Member

It's written in Obj-C but its compatible with Swift (more so if we use CocoaPods and just set the variable use_frameworks!).

You can see it in action on Ash Furrow's Moya.

The Demo uses OHHTTPStubs on its tests.

@czechboy0
Copy link
Member Author

Ok, DVR isn't on Cocoapods, let me try with Carthage (this is my first time, be patient).

@cojoj
Copy link
Contributor

cojoj commented Jun 27, 2015

I guess, that's the point when we have to get back to #5. There's no other way for us to handle mocking/stubbing without third-party, right?

@esttorhe
Copy link
Member

@czechboy0 as long as its on a public Github and has a shared scheme its going to be available in Carthage

@czechboy0
Copy link
Member Author

@cojoj This is exactly an example of where I much prefer to use a third party solution, instead of rolling my own. The recording approach is very simple and pretty much exactly how I was planning to do it manually anyway.

@czechboy0
Copy link
Member Author

@esttorhe Cool, reading the docs of Carthage atm.

@czechboy0
Copy link
Member Author

Carthage-related question: should I put the whole Carthage folder into gitignore? Or just the checkout? Or just the build? Or both?

@esttorhe
Copy link
Member

TBH I've seen people checking in everything.

That depends on how you want to link. Some people use Carthage with update --no-build and only download the source and integrate the projects to their project inside a workspace (meaning you won't end up with Builds folder at all)

Or you could depend on Carthage to generate the frameworks and just add the generated package; which means that you'll have to keep the Builds folder on the repo.

@esttorhe
Copy link
Member

Personally I just commit everything and depending on the project I use workspaces with the source code rather than the .frameworks

@czechboy0
Copy link
Member Author

Ok, I did something in between: ad1e5e2. I went for the full manual approach, using Carthage to just pull the repo into its folder, but not build it. Then, I added the project as a subproject to XcodeServerSDK and added the appropriate dependencies for building and linking. But, since the code is not ours, I added the Checkouts folder to gitignore, so when this gets merged, you guys will need to run carthage update --no-build (which I also added to the README).

Let me know if this is a reasonable approach or not.

@czechboy0
Copy link
Member Author

When it comes to this issue, thanks guys, I think I'll try DVR for now. I'll reopen if it doesn't work well.

@esttorhe
Copy link
Member

👌 sounds good

@czechboy0
Copy link
Member Author

Ok, now we can actually start using it :)

@cojoj
Copy link
Contributor

cojoj commented Jun 27, 2015

Bravo 👏 Hope that DVR will work for us!

@cojoj
Copy link
Contributor

cojoj commented Jun 27, 2015

Puls, nice job with advertising XcodeServerSDK 👍

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

No branches or pull requests

3 participants