Skip to content

buildasaurs/DVR

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DVR

Version Carthage compatible

DVR is a simple Swift framework for making fake NSURLSession requests based on VCR for iOS, watchOS, and OS X.

Easy dependency injection is the main design goal. The API is the same as NSURLSession. DVR.Session is a subclass of NSURLSession so you can use it as a drop in replacement anywhere. (Currently only data tasks are supported.)

Building

Xcode 7 is required since DVR is written in Swift 2.

Usage

let session = Session(cassetteName: "example")
let task = session.dataTaskWithRequest(request) { data, response, error in
  // Do something with the response
}

// Nothing happens until you call `resume` as you'd expect.
task.resume()

This will playback the example cassette. The completion handler exactly the same way it normally would. In this example, DVR will look for a cassette named example.json in your test bundle.

If the recording of the request is missing, it will record and save it to disk. After saving to disk, it will assert with path of the recorded file. This causes the tests to stop so you can add the cassette to your test target and rerun your tests.

Packages

No packages published

Languages

  • Swift 96.1%
  • Ruby 2.8%
  • Objective-C 1.1%