{"id":18716310,"url":"https://github.com/newmarcel/recordersession","last_synced_at":"2025-04-12T13:30:49.534Z","repository":{"id":40589327,"uuid":"89140403","full_name":"newmarcel/RecorderSession","owner":"newmarcel","description":"An NSURLSession test framework, inspired by DVR and VCR","archived":true,"fork":false,"pushed_at":"2022-06-26T19:36:57.000Z","size":308,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-19T01:41:33.043Z","etag":null,"topics":["ios","macos","nsurlsession","objective-c","swift","unittest"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/newmarcel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-23T12:33:46.000Z","updated_at":"2024-04-27T08:15:28.000Z","dependencies_parsed_at":"2022-09-17T08:20:19.781Z","dependency_job_id":null,"html_url":"https://github.com/newmarcel/RecorderSession","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmarcel%2FRecorderSession","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmarcel%2FRecorderSession/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmarcel%2FRecorderSession/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmarcel%2FRecorderSession/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/newmarcel","download_url":"https://codeload.github.com/newmarcel/RecorderSession/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248573408,"owners_count":21126824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","macos","nsurlsession","objective-c","swift","unittest"],"created_at":"2024-11-07T13:12:09.415Z","updated_at":"2025-04-12T13:30:49.088Z","avatar_url":"https://github.com/newmarcel.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/newmarcel/RecorderSession/master/Icon%402x.png\" width=\"64\" height=\"64\" /\u003e\n\n# RecorderSession\n\n[Docs](https://newmarcel.github.io/RecorderSession/index.html) | [Downloads](https://github.com/newmarcel/RecorderSession/releases)\n\n![Test](https://github.com/newmarcel/RecorderSession/workflows/Test/badge.svg?branch=master)\n\nAn `NSURLSession` test framework for iOS and macOS inspired by [DVR](https://github.com/venmo/DVR) and [VCR](https://github.com/vcr/vcr) _(that's where the cassette metaphor comes from…)_.\n\nIt's not as mature as DVR yet, but there are some advantages:\n\n- cassettes are stored in a `Cassettes.bundle` folder and don't pollute your Xcode project file\n- customizable validation options for comparing a request against the recorded request, e.g. excluding the host component to allow multple base URLs\n- works great with Swift, but doesn't depend on it\n    - Objective-C support was the primary motivation for creating this framework\n\n## Usage\n\nTo allow `NSURLSession` testing, please make sure your API client's session can be either switched out or added in via dependency injection in the initializer.\n\nYour test target should contain a `Cassettes.bundle` folder where all the recorded cassettes are stored.\n\n```swift\nimport RecorderSession\n\nlet bundle = Bundle(for: type(of: self)).cassetteBundle\n\n// Switch your URLSession with RecorderSession.\n// The original URLSession will be used for recording cassettes.\nlet recorderSession = RCNRecorderSession(backing: originalURLSession, cassetteBundle: bundle)\nlet client = MyAPIClient(session: recorderSession)\n\n// Load a cassette to record or replay\nrecorderSession.insertCassette(name: \"GetItems\")\n\n// Perform your network request\nclient.getItems { items, error in\n    XCTAssertNotNil(items)\n    XCTAssertNil(error)\n\n    expectation.fulfill()\n}\n```\n\nWhen you run the test for the first time, the cassette will be written to disk and the execution will halt. You need to move the cassette file from the printed location to your cassette bundle. All following test runs will use the cassette instead.\n\n## Installation via Carthage\n\nCarthage is the preferred, but not the only way to add this framework to your project. Add the following line to your `Cartfile.private` and run `carthage update`:\n\n```\ngithub \"newmarcel/RecorderSession\"\n```\n\n## Naming\n\n- **\"Cassette\"**: A JSON file representing an HTTP request, response and body.\n- **\"recording a cassette\"**: Making a live HTTP request and save the request, response and payload to disk.\n- **\"playing a cassette\"**: Simulating a live HTTP request, response and body with the saved JSON _\"cassette\"_ from disk.\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewmarcel%2Frecordersession","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnewmarcel%2Frecordersession","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewmarcel%2Frecordersession/lists"}