Skip to content

Commit

Permalink
Merge pull request #216 from marcelofabri/ohhttpStubs_httpBody
Browse files Browse the repository at this point in the history
Add OHHTTPStubs_HTTPBody to URLRequest in Swift 3.0
  • Loading branch information
AliSoftware committed Oct 23, 2016
2 parents a4c71a7 + 28e9d20 commit 9ce2a87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions OHHTTPStubs/Sources/Swift/OHHTTPStubsSwift.swift
Expand Up @@ -28,6 +28,11 @@


#if swift(>=3.0)
extension URLRequest {
public var ohhttpStubs_httpBody: Data? {
return (self as NSURLRequest).ohhttpStubs_HTTPBody()
}
}
#else
#if swift(>=2.2)
extension OHHTTPStubs {
Expand Down
9 changes: 9 additions & 0 deletions OHHTTPStubs/UnitTests/Test Suites/SwiftHelpersTests.swift
Expand Up @@ -382,4 +382,13 @@ class SwiftHelpersTests : XCTestCase {
XCTAssert((!falseMatcher)(req) == true, "!falseMatcher should result in a trueMatcher")
}
}

#if swift(>=3.0)
func test_ohhttpStubs_httpBody {
var req = URLRequest(url: URL(string: "foo://bar")!)
req.httpBody = Data()

XCTAssert(req.ohhttpStubs_httpBody == req.httpBody)
}
#endif
}

0 comments on commit 9ce2a87

Please sign in to comment.