{"id":13719774,"url":"https://github.com/devxoul/RxExpect","last_synced_at":"2025-05-07T11:32:36.428Z","repository":{"id":55386270,"uuid":"65238963","full_name":"devxoul/RxExpect","owner":"devxoul","description":"RxSwift testing framework","archived":true,"fork":false,"pushed_at":"2021-01-07T13:46:44.000Z","size":114,"stargazers_count":104,"open_issues_count":6,"forks_count":29,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-11T05:03:14.090Z","etag":null,"topics":["rxswift","test"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/devxoul.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":"2016-08-08T21:00:48.000Z","updated_at":"2024-03-04T04:44:10.000Z","dependencies_parsed_at":"2022-08-14T23:10:22.821Z","dependency_job_id":null,"html_url":"https://github.com/devxoul/RxExpect","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FRxExpect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FRxExpect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FRxExpect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devxoul%2FRxExpect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devxoul","download_url":"https://codeload.github.com/devxoul/RxExpect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252869172,"owners_count":21816987,"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":["rxswift","test"],"created_at":"2024-08-03T01:00:55.285Z","updated_at":"2025-05-07T11:32:33.968Z","avatar_url":"https://github.com/devxoul.png","language":"Swift","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"RxExpect\n========\n\n![Swift](https://img.shields.io/badge/Swift-5.0-orange.svg)\n[![CocoaPods](http://img.shields.io/cocoapods/v/RxExpect.svg)](https://cocoapods.org/pods/RxExpect)\n[![Build Status](https://travis-ci.org/devxoul/RxExpect.svg?branch=master)](https://travis-ci.org/devxoul/RxExpect)\n[![Codecov](https://img.shields.io/codecov/c/github/devxoul/RxExpect.svg)](https://codecov.io/gh/devxoul/RxExpect/)\n\nRxExpect is a testing framework for RxSwift.\n\n## Concept\n\nProvide inputs then test outputs. This is an example code that tests `map()` operator multiplying the values by 2.\n\n```swift\nfunc testMultiply() {\n  let test = RxExpect()\n  let value = PublishSubject\u003cInt\u003e()\n  let result = value.map { $0 * 2 }\n\n  // provide inputs\n  test.input(value, [\n    next(100, 1),\n    next(200, 2),\n    next(300, 3),\n    completed(400)\n  ])\n  \n  // test output\n  test.assert(result) { events in\n    XCTAssertEqual(events, [\n      next(100, 2),\n      next(200, 4),\n      next(300, 6),\n      completed(400)\n    ])\n  }\n}\n```\n\nIt would be easy to understand if you imagine the marble diagram.\n\n```\ntime   --100-200-300-400 // virtual timeline\nvalue  --1---2---3---|   // provide inputs\nresult --2---4---6---|   // test these values\n```\n\nThis is more complicated example.\n\n```swift\nfinal class ArticleDetailViewModelTests: XCTestCase {\n  func testLikeButtonSelected() {\n    let test = RxExpect()\n    let viewModel = ArticleDetailViewModel()\n    test.retain(viewModel) // IMPORTANT: prevent from being disposed while testing\n\n    // providing an user input: user tapped like button\n    test.input(viewModel.likeButtonDidTap, [\n      next(100, Void()),\n    ])\n\n    // test output: like button become selected\n    test.assert(viewModel.isLikeButtonSelected) { events in\n      XCTAssertEqual(events.at(100...).elements, [true])\n    }\n  }\n\n  func testLikeButtonUnselected() {\n    let test = RxExpect()\n    let viewModel = ArticleDetailViewModel()\n    test.retain(viewModel) // IMPORTANT: prevent from being disposed while testing\n\n    // providing an user input: user tapped like button\n    test.input(viewModel.likeButtonDidTap, [\n      next(100, Void()),\n    ])\n\n    // test output: like button become selected\n    test.assert(viewModel.isLikeButtonSelected) { events in\n      XCTAssertEqual(events.at(100...).elements, [false])\n    }\n  }\n}\n```\n\n## Examples\n\n* [RxTodo](https://github.com/devxoul/RxTodo/tree/master/RxTodoTests/Sources/Tests)\n* [Drrrible](https://github.com/devxoul/Drrrible/tree/master/DrrribleTests/Sources)\n\n## APIs\n\n#### Providing Inputs\n\n* `input(observer, events)`\n* `input(variable, events)`\n\n#### Start Assertion Chaining\n\n* `assert(source, closure)`\n\n## Installation\n\n- **For iOS 8+ projects** with [CocoaPods](https://cocoapods.org):\n\n    ```ruby\n    pod 'RxExpect'\n    ```\n\n- **For iOS 8+ projects** with [Carthage](https://github.com/Carthage/Carthage):\n\n    ```\n    github \"devxoul/RxExpect\"\n    ```\n\n## Development\n\n```console\n$ swift package generate-xcodeproj\n$ open RxExpect.xcodeproj\n```\n\n## License\n\nRxExpect is under MIT license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevxoul%2FRxExpect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevxoul%2FRxExpect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevxoul%2FRxExpect/lists"}