 
         switch rule.response {
         case .NetworkResponse(let statusCode, let data):
-            let response = NSHTTPURLResponse(URL: rule.endpoint.URL, statusCode: statusCode, HTTPVersion: nil, headerFields: nil)
+            let response = NSHTTPURLResponse(URL: rule.URL, statusCode: statusCode, HTTPVersion: nil, headerFields: nil)
             completion(response: response, data: data, error: nil)
         case .NetworkError(let error):
             completion(response: nil, data: nil, error: error)

}

public struct StubRule {
    let endpoint: Endpoint
    let behavior: StubBehavior
    let response: StubResponse

    public init(endpoint: Endpoint, behavior: StubBehavior, response: StubResponse) {
        self.endpoint = endpoint
        self.behavior = behavior
        self.response = response
    }
}

internal final class StubCancellableToken: Cancellable {

}

public class StubBackend: BackendType {
    private var stubs: [StubAction: StubRule]

    public init() {
        self.stubs = [:]
    }

    public func stubTarget(target: TargetType, response: StubResponse, behavior: StubBehavior = .Immediate) {
        let action = StubAction(URL: target.fullURL, method: target.method)
        let rule = StubRule(URL: target.fullURL, behavior: behavior, response: response)

        self.stubs[action] = rule
    }

    public func removeAllStubs() {
        self.stubs = [:]
    }

    public func removeStub(target: TargetType) {
        let action = StubAction(URL: target.fullURL, method: target.method)

        self.stubs.removeValueForKey(action)
    }

    public func request(request: NSURLRequest, completion: (response: NSHTTPURLResponse?, data: NSData?, error: NSError?) -> ()) -> Cancellable {
        let action = StubAction(URL: request.URL!, method: Method(rawValue: request.HTTPMethod!)!)
        guard let stubRule = self.stubs[action] else {
            fatalError("Request not stubbed yet.")
        }

