Latest 0.0.1
Homepage https://github.com/JanGorman/Hippolyte
License MIT
Platforms ios 9.3
Authors

Build Status
Version
License
Platform

An HTTP stubbing library written in Swift.

Requirements

  • Swift 4
  • iOS 9.3+
  • Xcode 9+

Install

Hippolyte is available on Cocoapods. Add it to your Podfile‘s test target:

pod 'Hippolyte'

Usage

To stub a request, first you need to create a StubRequest and StubResponse. You then register this stub with Hippolyte and tell it to intercept network requests by calling the start() method.

func testStub() {
    let url = URL(string: "http://www.apple.com")!
    var stub = StubRequest(method: .GET, url: url)
    var response = StubResponse()
    let body = "Hippolyte".data(using: .utf8)!
    response.body = body
    stub.response = response
    Hippolyte.shared.add(stubbedRequest: stub)
    Hippolyte.shared.start()

    let expectation = self.expectation(description: "Stubs network call")
    let task = URLSession.shared.dataTask(with: url) { data, _, _ in
      XCTAssertEqual(data, body)
      expectation.fulfill()
    }
    task.resume()

    wait(for: [expectation], timeout: 1)
}

Remember to tear down stubbing in your tests:

override func tearDown() {
    super.tearDown()
    Hippolyte.shared.stop()
}

You can configure your stub response in a number of ways, such as having it return different HTTP status codes, headers, and errors.

License

Hippolyte is released under the MIT license. See LICENSE for details

Latest podspec

{
    "name": "Hippolyte",
    "version": "0.0.1",
    "summary": "HTTP Stubbing in Swift",
    "description": "Easily stub HTTP requests in your tests. Hippolyte makes your tests run fast and reliable without hitting the network.",
    "homepage": "https://github.com/JanGorman/Hippolyte",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jan Gorman": "[email protected]"
    },
    "social_media_url": "http://twitter.com/JanGorman",
    "platforms": {
        "ios": "9.3"
    },
    "source": {
        "git": "https://github.com/JanGorman/Hippolyte.git",
        "tag": "0.0.1"
    },
    "source_files": [
        "Classes",
        "Hippolyte/*.swift"
    ],
    "pushed_with_swift_version": "4"
}

Pin It on Pinterest

Share This