venmo / DVR

Network testing for Swift
http://blog.soff.es/network-testing-in-swift-with-dvr
MIT License
651 stars 86 forks source link

Batch recording. Closes #6 #31

Closed soffes closed 8 years ago

soffes commented 8 years ago

Support for recording multiple interactions. This also includes #29 since the recorded cassettes had plain text in them.

soffes commented 8 years ago

I've tested this throughly both in DVR and in an application using DVR. Everything works as expected!

Here's an example. In this client, it's one request to get a token and one request to show the user to build a full Account (token + user). This passes as expected with this change :grinning:

func testSignIn() {
    let expectation = expectationWithDescription("Networking")

    let dvr = Session(cassetteName: "sign-in")
    dvr.beginRecording()

    let client = AuthorizationClient(session: dvr)

    client.signIn(username: "soffes", password: "REDACTED_PASSWORD") {
        switch $0 {
        case .Success(let account):
            XCTAssertEqual("REDACTED_TOKEN", account.accessToken)
            XCTAssertEqual("soffes", account.user.username)
        case .Failure(let message):
            XCTFail(message)
        }

        dvr.endRecording() {
            expectation.fulfill()
        }
    }

    waitForExpectationsWithTimeout(1, handler: nil)
}
soffes commented 8 years ago

@ayanonagon ready to go!