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

Code before:
                    var log = ""
                    var plugin: NetworkLoggerPlugin!
                    beforeEach {
                        log = ""

                        plugin = NetworkLoggerPlugin(verbose: true, output: { (_, _, printing: Any...) in
                            //mapping the Any... from items to a string that can be compared
                            let stringArray: [String] = printing.map { $0 as? String }.flatMap { $0 }
                            let string: String = stringArray.reduce("") { $0 + $1 + " " }
                            log += string
                        })
                    }

                    it("logs the request") {

                        let provider = MoyaProvider<GitHub>(plugins: [plugin])
                        waitUntil { done in
                            provider.request(.zen) { _ in done() }
                        }

                        expect(log).to( contain("Request:") )
                        expect(log).to( contain("{ URL: https://api.github.com/zen }") )
                        expect(log).to( contain("Request Headers: [:]") )
                        expect(log).to( contain("HTTP Request Method: GET") )
                        expect(log).to( contain("Response:") )
                        expect(log).to( contain("{ URL: https://api.github.com/zen } { Status Code: 200, Headers") )
                        expect(log).to( contain("\"Content-Length\" =") )
                        expect(log).to( contain("43"))
                    }
                }
            }

            describe("a reactive provider with SignalProducer") {
                var provider: MoyaProvider<GitHub>!
                beforeEach {
                    provider = MoyaProvider<GitHub>()
                }

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

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

                    expect(message) == zenMessage

Review comment (suggestion):
I had to make some changes here but I think they're unrelated to the PR. I was getting the string back with a different capitalization. It also returns the content-length, 43, wrapped in parentheses now. No matter what I tried I couldn't get `(43);` == `(43);` String testing is brittle

Code after:
                    var log = ""
                    var plugin: NetworkLoggerPlugin!
                    beforeEach {
                        log = ""

                        plugin = NetworkLoggerPlugin(verbose: true, output: { (_, _, printing: Any...) in
                            //mapping the Any... from items to a string that can be compared
                            let stringArray: [String] = printing.map { $0 as? String }.flatMap { $0 }
                            let string: String = stringArray.reduce("") { $0 + $1 + " " }
                            log += string
                        })
                    }

                    it("logs the request") {

                        let provider = MoyaProvider<GitHub>(plugins: [plugin])
                        waitUntil { done in
                            provider.request(.zen) { _ in done() }
                        }

                        expect(log).to( contain("Request:") )
                        expect(log).to( contain("{ URL: https://api.github.com/zen }") )
                        expect(log).to( contain("Request Headers: [:]") )
                        expect(log).to( contain("HTTP Request Method: GET") )
                        expect(log).to( contain("Response:") )
                        expect(log).to( contain("{ URL: https://api.github.com/zen } { status code: 200, headers") )
                        expect(log).to( contain("\"Content-Length\" = 43;") )
                    }
                }
            }

            describe("a reactive provider with SignalProducer") {
                var provider: MoyaProvider<GitHub>!
                beforeEach {
                    provider = MoyaProvider<GitHub>()
                }

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

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

                    expect(message) == zenMessage
                }