From 6efca194d226b46f99e5865c042579f49f97575f Mon Sep 17 00:00:00 2001 From: Kyle Fuller Date: Wed, 28 Sep 2016 16:57:40 +0100 Subject: [PATCH] Update README for Swift 3.0 This reverts commit 2ddd3af5fdab111035fb55aaef7483f642611050. --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ed4e2ed..30b8f17 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Mockingjay has full integration to XCTest and you simply just need to register a ```swift let body = [ "user": "Kyle" ] -stub(uri("/{user}/{repository}"), builder: json(body)) +stub(uri("/{user}/{repository}"), json(body)) ``` The `uri` function takes a URL or path which can have a [URI Template](https://github.com/kylef/URITemplate.swift). Such as the following: @@ -32,22 +32,24 @@ The `uri` function takes a URL or path which can have a [URI Template](https://g ```swift let body = [ "description": "Kyle" ] -stub(http(.PUT, uri: "/kylef/Mockingjay"), builder: json(body)) +stub(http(.PUT, "/kylef/Mockingjay"), json(body)) ``` #### Stubbing everything request to result in an error ```swift -let error = NSError(domain: "Mockingjay Session Tests", code: 0, userInfo: nil) -stub(everything, builder: failure(error)) +let error = NSError() +stub(everything, failure(error)) ``` #### Stub with a specific HTTP response ```swift -stub(everything, builder: http(404, headers: nil, data: nil)) +stub(everything, http(status: 404)) ``` +*Note, the `http` builder can take a set of headers and a body too.* + ## Stub The `stub` method in Mockingjay takes two functions or closures, one to match the request and another to build the response. This allows you to easily extend the syntax to provide your own specific functions. @@ -65,7 +67,7 @@ func matcher(request:NSURLRequest) -> Bool { return true // Let's match this request } -stub(matcher, builder: failure(error)) +stub(matcher, failure(error)) ``` ### Builders @@ -78,7 +80,7 @@ func builder(request:NSURLRequest) -> Response { return .Success(response, .NoContent) } -stub(matcher, builder: builder) +stub(matcher, builder) ``` ### Generics