Latest 0.1.0
Homepage https://github.com/kylef/Mockingdrive
License MIT
Platforms ios 8.0, osx 10.9, requires ARC
Dependencies Representor, Mockingjay
Frameworks XCTest
Authors

Framework for stubbing Hypermedia HTTP requests. Making use of
Mockingjay and the
Swift Representor.

Usage

Mockingdrive can be used to stub any requests matching a Mockingjay matcher by
a Representor. Here’s an example of using the Representor builder pattern:

stubRepresentor(uri("/questions")) {
  $0.addTransition("next", uri: "/questions?page=2")
  $0.addAttribute("count", value: 22)
}

You can also pass in directory a representor structure:

stub(everything, representor)

Full example using the Hyperdrive Hypermedia client.

class QuestionTests : XCTestCase {
  let hyperdrive = Hyperdrive()

  func testQuestions() {
    // Stub /questions using the Representor builder pattern
    stubRepresentor(uri("/questions")) {
      $0.addTransition("next", uri:"/questions?page=2")
      $0.addAttribute("count", value: 22)
    }

    // Use an XCTest expectation, so our tests wait for the request to finish
    let expectation = expectationWithDescription("Mockingdrive")

    // Perform request (using Hyperdrive, you can use other networking libraries)
    hyperdrive.enter("https://polls.apiblueprint.org/questions") { result in
      switch result {
      case .Success(let representor):
        // Assert we have a transition for using the "next" relation
        XCTAssertNotNil(representor.transitions["next"])
        expectation.fulfill()
      case .Failure:
        XCTFail("Unexpected Failure")
      }
    }

    waitForExpectationsWithTimeout(1.0, handler: nil)
  }
}

Installation

CocoaPods is the recommended way to add Mockingdrive
to your project.

pod 'Mockingdrive'

License

Mockingdrive is released under the MIT license. See LICENSE.

Latest podspec

{
    "name": "Mockingdrive",
    "version": "0.1.0",
    "summary": "Testing framework for stubbing Hypermedia HTTP requests",
    "homepage": "https://github.com/kylef/Mockingdrive",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Kyle Fuller": "[email protected]"
    },
    "social_media_url": "http://twitter.com/kylefuller",
    "source": {
        "git": "https://github.com/kylef/Mockingdrive.git",
        "tag": "0.1.0"
    },
    "source_files": "Mockingdrive/*.{h,swift}",
    "frameworks": "XCTest",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9"
    },
    "requires_arc": true,
    "dependencies": {
        "Representor": [],
        "Mockingjay": [
            "~> 1.0"
        ]
    }
}

Pin It on Pinterest

Share This