 class NSMutableURLRequestExtensionsSpec: QuickSpec {
     override func spec() {
         describe("-setHTTPAuthorization") {
-            it("resets the HTTP Authorization Header if given nil") {
+            it("resets the Authorization header if given nil") {
                 let authentication: HTTPAuthentication = .BasicAuthentication(username: "username", password: "password")
 
                 let request = NSMutableURLRequest()

                expect(result).to(beNil())
            }

            it("sets the HTTP Authorization Header accordingly if given BasicAuthentication") {
                let authentication: HTTPAuthentication = .BasicAuthentication(username: "username", password: "password")

                let request = NSMutableURLRequest()
                request.setHTTPAuthorization(authentication)

                let result = request.valueForHTTPHeaderField("Authorization")

                expect(result).to(equal("Basic dXNlcm5hbWU6cGFzc3dvcmQ="))
            }

            it("sets the HTTP Authorization Header accordingly if given Unknown") {
                let authentication: HTTPAuthentication = .Unknown(value: "value")

                let request = NSMutableURLRequest()
                request.setHTTPAuthorization(authentication)

                let result = request.valueForHTTPHeaderField("Authorization")

                expect(result).to(equal("value"))
            }
        }
    }

class NSURLRequestExtensionsSpec: QuickSpec {
    override func spec() {
        describe(".HTTPAuthorization") {
            it("returns nil if the Authorization header is not set") {
                let request = NSURLRequest()

                expect(request.HTTPAuthorization).to(beNil())
            }

            context("when the Authorization header is set to Basic Authentication") {
                it("returns .BasicAuthentication with decoded username and password") {
                    let authentication: HTTPAuthentication = .BasicAuthentication(username: "username", password: "password")

                    let request = NSMutableURLRequest()
                    request.setValue("Basic dXNlcm5hbWU6cGFzc3dvcmQ=", forHTTPHeaderField: "Authorization")

                    let result = request.HTTPAuthorization

                    expect(result).to(equal(authentication))
                }
            }

            context("when the Authorization header is set to an unknown authentication") {
                it("returns .Unknown with the header's value") {
                    let authentication: HTTPAuthentication = .Unknown(value: "value")

                    let request = NSMutableURLRequest()
                    request.setValue("value", forHTTPHeaderField: "Authorization")

                    let result = request.HTTPAuthorization

                    expect(result).to(equal(authentication))
                }
            }
        }
    }
