Repository: Moya/Moya
File: Tests/MoyaProviderIntegrationTests.swift (Swift)

Code before:
                    }

                    expect(message) == zenMessage
                }

                it("returns some data for user profile request") {
                    var message: String?

                    waitUntil { done in
                        let target: GitHub = .userProfile("ashfurrow")
                        provider.reactive.request(target).startWithResult { result in
                            if case .success(let response) = result {
                                message = String(data: response.data, encoding: String.Encoding.utf8)
                                done()
                            }
                        }
                    }

                    expect(message) == userMessage
                }
            }
        }

        // Resolves ValidationType not working with multipart upload #1590
        describe("a provider performing a multipart upload with Alamofire validation") {
            it("only allows status code 287") {
                let formData = HTTPBin.createMultipartFormData()
                let target = HTTPBin.validatedUploadMultipart(formData, nil)
                let provider = MoyaProvider<HTTPBin>()
                var receievedResponse: Response?
                var receivedError: Error?
                waitUntil(timeout: 5.0) { done in
                    provider.request(target) { result in
                        switch result {
                        case .success(let response):
                            receievedResponse = response
                        case .failure(let error):
                            receivedError = error
                        }
                        done()
                    }
                }
                expect(receievedResponse).to(beNil())
                expect(receivedError).toNot(beNil())
            }
        }
    }
}

final class StubManager: Manager {
    var called = false

Review comment (suggestion):
how about `it returns error for status code different than 287` and then we could add another case `it returns valid response for status code 287`

Code after:
                    }

                    expect(message) == zenMessage
                }

                it("returns some data for user profile request") {
                    var message: String?

                    waitUntil { done in
                        let target: GitHub = .userProfile("ashfurrow")
                        provider.reactive.request(target).startWithResult { result in
                            if case .success(let response) = result {
                                message = String(data: response.data, encoding: String.Encoding.utf8)
                                done()
                            }
                        }
                    }

                    expect(message) == userMessage
                }
            }
        }

        // Resolves ValidationType not working with multipart upload #1590
        describe("a provider performing a multipart upload with Alamofire validation") {
            let provider = MoyaProvider<HTTPBin>()
            let formData = HTTPBin.createTestMultipartFormData()

            it("returns an error for status code different than 287") {
                let target = HTTPBin.validatedUploadMultipart(formData, nil, [287])
                var receievedResponse: Response?
                var receivedError: Error?

                waitUntil(timeout: 5.0) { done in
                    provider.request(target) { result in
                        switch result {
                        case .success(let response):
                            receievedResponse = response
                        case .failure(let error):
                            receivedError = error
                        }
                        done()
                    }
                }

                expect(receievedResponse).to(beNil())
                expect(receivedError).toNot(beNil())
            }

            it("returns a valid response for .succesCodes") {
                let successCodes = ValidationType.successCodes.statusCodes