summaryrefslogtreecommitdiff
path: root/test/ios/OHHTTPStubs/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'test/ios/OHHTTPStubs/README.md')
-rw-r--r--test/ios/OHHTTPStubs/README.md19
1 files changed, 13 insertions, 6 deletions
diff --git a/test/ios/OHHTTPStubs/README.md b/test/ios/OHHTTPStubs/README.md
index dafd89fa53..2c9c831393 100644
--- a/test/ios/OHHTTPStubs/README.md
+++ b/test/ios/OHHTTPStubs/README.md
@@ -22,6 +22,9 @@ It works with `NSURLConnection`, new iOS7/OSX.9's `NSURLSession`, `AFNetworking`
`OHHTTPStubs` headers are fully documented using Appledoc-like / Headerdoc-like comments in the header files. You can also [read the **online documentation** here](http://cocoadocs.org/docsets/OHHTTPStubs)
[![Version](http://cocoapod-badges.herokuapp.com/v/OHHTTPStubs/badge.png)](http://cocoadocs.org/docsets/OHHTTPStubs)
+## Swift support
+
+`OHHTTPStubs` is compatible with Swift out of the box: you can use it with the same API as you would use in Objective-C. But you might also want to include the `OHHTTPStubs/Swift` subspec in your `Podfile`, which adds some global function helpers (see `OHHTTPStubsSwift.swift`) to make the use of `OHHTTPStubs` more compact and Swift-like.
## Basic example
@@ -40,15 +43,18 @@ It works with `NSURLConnection`, new iOS7/OSX.9's `NSURLSession`, `AFNetworking`
### In Swift
+This example is using the Swift helpers found in `OHHTTPStubsSwift.swift` provided by the `OHHTTPStubs/Swift` subspec
+
```swift
-OHHTTPStubs.stubRequestsPassingTest({$0.URL!.host == "mywebservice.com"}) { _ in
+stub(isHost("mywebservice.com")) { _ in
// Stub it with our "wsresponse.json" stub file (which is in same bundle as self)
- let fixture = OHPathForFile("wsresponse.json", self.dynamicType)
- return OHHTTPStubsResponse(fileAtPath: fixture!,
- statusCode: 200, headers: ["Content-Type":"application/json"])
+ let stubPath = OHPathForFile("wsresponse.json", self.dynamicType)
+ return fixture(stubPath!, headers: ["Content-Type":"application/json"])
}
```
+Note: Using `OHHTTPStubsSwift.swift` you could also compose the matcher functions like this: `stub(isScheme("http") && isHost("myhost")) { … }`
+
## More examples & Help Topics
* For a lot more examples, see the dedicated "[Usage Examples](https://github.com/AliSoftware/OHHTTPStubs/wiki/Usage-Examples)" wiki page.
@@ -97,7 +103,7 @@ _As far as I know, there's nothing we can do about those two limitations. Please
## Submitting to the AppStore
-`OHHTTPStubs` **can be used** on apps subbmiting **on the AppStore**. It does not use any private API and nothing prevents you from shipping it.
+`OHHTTPStubs` **can be used** on apps submitted **on the AppStore**. It does not use any private API and nothing prevents you from shipping it.
But you generally only use stubs during the development phase and want to remove your stubs when submitting to the AppStore. So be careful to only include `OHHTTPStubs` when needed (only in your test targets, or only inside `#if DEBUG` portions, or by using [per-Build-Configuration pods](https://guides.cocoapods.org/syntax/podfile.html#pod)) to avoid forgetting to remove it when the time comes that you release for the AppStore and you want your requests to hit the net!
@@ -108,6 +114,7 @@ But you generally only use stubs during the development phase and want to remove
This project and library has been created by Olivier Halligon (@aligatr on Twitter) and is under the MIT License.
It has been inspired by [this article from InfiniteLoop.dk](http://www.infinite-loop.dk/blog/2011/09/using-nsurlprotocol-for-injecting-test-data/).
-I would also like to thank to @kcharwood for its contribution, and everyone who contributed to this project on GitHub.
+
+I would also like to thank Kevin Harwood ([@kcharwood](https://github.com/kcharwood)) for migrating the code to `NSInputStream`, Jinlian Wang ([@JinlianWang](https://github.com/JinlianWang)) for adding Mocktail support, and everyone else who contributed to this project on GitHub somehow.
If you want to support the development of this library, feel free to [![Donate](http://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TRTU3UEWEHV92 "Donate"). Thanks to all contributors so far!