Skip to content

Commit

Permalink
Merge pull request #146 from attheodo/master
Browse files Browse the repository at this point in the history
Added `isMethodPATCH()` to `Swift` helpers
  • Loading branch information
AliSoftware committed Dec 20, 2015
2 parents 44993ab + 88c1afe commit 89de14b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# OHHTTPStubs — CHANGELOG
## [4.7.0](https://github.com/AliSoftware/OHHTTPStubs/releases/tag/4.7.0)

* Added `isMethodPATCH()` to the `Swift` helpers.
[@attheodo](https://github.com/attheodo)([#145](https://github.com/AliSoftware/OHHTTPStubs/issues/145))

## [4.6.0](https://github.com/AliSoftware/OHHTTPStubs/releases/tag/4.5.1)

Expand Down Expand Up @@ -62,7 +66,7 @@
* Fix threading in `NSURLProtocol` subclass calling `NSURLProtocolClient` callbacks from wrong thread.
[@nsprogrammer](https://github.com/nsprogrammer), [#96](https://github.com/AliSoftware/OHHTTPStubs/pull/96)

## [4.0.0](https://github.com/AliSoftware/OHHTTPStubs/releases/tag/4.0.0) — Improvements for Swift
## [4.0.0](https://github.com/AliSoftware/OHHTTPStubs/releases/tag/4.0.0) — Improvements for Swift

* Annotated the library with _nullability_ attributes to generate a better API when used in Swift
* Migrated the path utility macros to functions in `OHPathHelpers.h`, for Swift compatibility ([#100](https://github.com/AliSoftware/OHHTTPStubs/issues/100)).
Expand Down
4 changes: 2 additions & 2 deletions OHHTTPStubs.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "OHHTTPStubs"
s.version = "4.6.0"
s.version = "4.7.0"

s.summary = "Framework to stub your network requests like HTTP and help you write network unit tests with XCTest."
s.description = <<-DESC.gsub(/^ +\|/,'')
Expand Down Expand Up @@ -83,7 +83,7 @@ Pod::Spec.new do |s|
swift.osx.deployment_target = '10.9'
swift.watchos.deployment_target = '2.0'
swift.tvos.deployment_target = '9.0'

swift.dependency 'OHHTTPStubs/Core'
swift.source_files = "OHHTTPStubs/Sources/Swift/*.swift"
end
Expand Down
10 changes: 10 additions & 0 deletions OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ public func isMethodPUT() -> OHHTTPStubsTestBlock {
return { $0.HTTPMethod == "PUT" }
}

/**
* Matcher testing that the `NSURLRequest` is using the **PATCH** `HTTPMethod`
*
* - Returns: a matcher (OHHTTPStubsTestBlock) that succeeds only if the request
* is using the PATCH method
*/
public func isMethodPATCH() -> OHHTTPStubsTestBlock {
return { $0.HTTPMethod == "PATCH" }
}

/**
* Matcher testing that the `NSURLRequest` is using the **DELETE** `HTTPMethod`
*
Expand Down
4 changes: 2 additions & 2 deletions OHHTTPStubs/UnitTests/Test Suites/SwiftHelpersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import OHHTTPStubs
class SwiftHelpersTests : XCTestCase {

func testHTTPMethod() {
let methods = ["GET","PUT","POST","DELETE","FOO"]
let matchers = [isMethodGET(), isMethodPUT(), isMethodPOST(), isMethodDELETE()]
let methods = ["GET", "PUT", "PATCH", "POST", "DELETE", "FOO"]
let matchers = [isMethodGET(), isMethodPUT(), isMethodPATCH(), isMethodPOST(), isMethodDELETE()]

for (idxMethod, method) in methods.enumerate() {
let req = NSMutableURLRequest(URL: NSURL(string: "foo://bar")!)
Expand Down

0 comments on commit 89de14b

Please sign in to comment.