Upgrade to Pro — share decks privately, control downloads, hide ads and more …

VCRURLConnection

Dustin Barker
November 20, 2013

 VCRURLConnection

An introduction to VCRURLConnection, an iOS and OSX API to record and replay HTTP interactions, inspired by VCR for ruby. Presented at Cocoa Kucha in New York City.

Dustin Barker

November 20, 2013
Tweet

Other Decks in Technology

Transcript

  1. VCRURLConnection records and replays HTTP interactions (inspired by VCR for

    ruby) HTTP GET HTTP GET HTTP 200 OK HTTP 200 OK
  2. apps connect to many services must degrade gracefully when any

    are unavailable Payments Transactions Messages x
  3. a recording can make these interactions repeatable (and easier to

    test) HTTP DELETE HTTP 200 HTTP DELETE HTTP 200
  4. to begin recording HTTP interactions with VCRURLConnection: [VCR start]; Before

    requests are made: (ex: application:didFinishLaunchingWithOptions:)
  5. [ { "method": "GET", "uri" : "http://foo.com/test.json", "headers" : {

    "Content-Type": "application/json", ... }, "body": { ... } } ... ] VCRURLConnection records request and response pairs to disk in JSON format
  6. to play a recording with VCRURLConnection: NSURL *url = [NSURL

    fileURLWithPath:path]; [VCR loadCassetteWithContentsOfURL:url]; [VCR start]; Before requests are made: (ex: application:didFinishLaunchingWithOptions:)
  7. Try VCRURLConnection platform :ios, '7.0' pod 'VCRURLConnection', '~> 0.1.1' git

    clone https://github.com/dstnbrkr/VCRURLConnection.git Download VCRURLConnection from Github Add VCRURLConnection to your Podfile