diff --git a/CHANGELOG.md b/CHANGELOG.md index 3af1fe70..48377a3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,12 @@ ## [Future release] * Enabled application extension API only. [@lightsprint09](https://github.com/lightsprint09) -* Disabled a flaky redirect test and adding the known issue with redirects to the README. - [@jeffctown](https://github.com/jeffctown) [#301](https://github.com/AliSoftware/OHHTTPStubs/pull/301) -* Updating Conditional Unit Test Compilation. - [@jeffctown](https://github.com/jeffctown) [#302](https://github.com/AliSoftware/OHHTTPStubs/pull/302) +* Disabled a flaky redirect test and adding the known issue with redirects to the README. + [@jeffctown](https://github.com/jeffctown) + [#301](https://github.com/AliSoftware/OHHTTPStubs/pull/301) +* Added `isMethodHEAD()` to the `Swift` helpers. + [@Simon-Kaz](https://github.com/Simon-Kaz) + [#294](https://github.com/AliSoftware/OHHTTPStubs/pull/294) ## [6.1.0](https://github.com/AliSoftware/OHHTTPStubs/releases/tag/6.1.0) diff --git a/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift b/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift index 963ac88a..7d9236e4 100644 --- a/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift +++ b/OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift @@ -163,6 +163,16 @@ public func isMethodDELETE() -> OHHTTPStubsTestBlock { return { $0.httpMethod == "DELETE" } } +/** + * Matcher testing that the `NSURLRequest` is using the **HEAD** `HTTPMethod` + * + * - Returns: a matcher (OHHTTPStubsTestBlock) that succeeds only if the request + * is using the HEAD method + */ +public func isMethodHEAD() -> OHHTTPStubsTestBlock { + return { $0.httpMethod == "HEAD" } +} + /** * Matcher for testing an `NSURLRequest`'s **absolute url string**. * diff --git a/OHHTTPStubs/UnitTests/Test Suites/SwiftHelpersTests.swift b/OHHTTPStubs/UnitTests/Test Suites/SwiftHelpersTests.swift index 3b636466..b76b80f7 100644 --- a/OHHTTPStubs/UnitTests/Test Suites/SwiftHelpersTests.swift +++ b/OHHTTPStubs/UnitTests/Test Suites/SwiftHelpersTests.swift @@ -35,8 +35,8 @@ import XCTest class SwiftHelpersTests : XCTestCase { func testHTTPMethod() { - let methods = ["GET", "PUT", "PATCH", "POST", "DELETE", "FOO"] - let matchers = [isMethodGET(), isMethodPUT(), isMethodPATCH(), isMethodPOST(), isMethodDELETE()] + let methods = ["GET", "PUT", "PATCH", "POST", "DELETE", "HEAD", "FOO"] + let matchers = [isMethodGET(), isMethodPUT(), isMethodPATCH(), isMethodPOST(), isMethodDELETE(), isMethodHEAD()] for (idxMethod, method) in methods.enumerated() { #if swift(>=3.0)