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

Added isMethodHEAD to swift helpers #294

Merged
merged 4 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# OHHTTPStubs — CHANGELOG

## [Future release]
* 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)

* Updated deployment target for the pod to 7.0 to remove warning for old APIs.
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 @@ -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**.
*
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 @@ -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)
Expand Down