From 4014f71d7f442a37fcf52206a8cd5950b7db7ae6 Mon Sep 17 00:00:00 2001 From: Suyeol Jeon Date: Mon, 25 Sep 2017 19:10:31 +0900 Subject: [PATCH 1/9] Use Swift 4 --- .swift-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.swift-version b/.swift-version index 8c50098..5186d07 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.1 +4.0 From fb7f0f801359400a4efb77515b0ba20d089a5296 Mon Sep 17 00:00:00 2001 From: Suyeol Jeon Date: Mon, 25 Sep 2017 19:10:41 +0900 Subject: [PATCH 2/9] Update Package.swift to V4 --- Package.pins | 18 ------------- Package.resolved | 25 +++++++++++++++++++ Package.swift | 13 +++++++--- .../NSViewController+Rx.swift | 0 .../UIViewController+Rx.swift | 0 5 files changed, 35 insertions(+), 21 deletions(-) delete mode 100644 Package.pins create mode 100644 Package.resolved rename Sources/{ => RxViewController}/NSViewController+Rx.swift (100%) rename Sources/{ => RxViewController}/UIViewController+Rx.swift (100%) diff --git a/Package.pins b/Package.pins deleted file mode 100644 index b196ce7..0000000 --- a/Package.pins +++ /dev/null @@ -1,18 +0,0 @@ -{ - "autoPin": true, - "pins": [ - { - "package": "RxExpect", - "reason": null, - "repositoryURL": "https://github.com/devxoul/RxExpect.git", - "version": "0.6.0" - }, - { - "package": "RxSwift", - "reason": null, - "repositoryURL": "https://github.com/devxoul/RxSwift.git", - "version": "3.4.2" - } - ], - "version": 1 -} \ No newline at end of file diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..72f88d9 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,25 @@ +{ + "object": { + "pins": [ + { + "package": "RxExpect", + "repositoryURL": "https://github.com/devxoul/RxExpect.git", + "state": { + "branch": "swift-4.0", + "revision": "b3726078bf37f699da9e7566b16c996e94e8d321", + "version": null + } + }, + { + "package": "RxSwift", + "repositoryURL": "https://github.com/ReactiveX/RxSwift.git", + "state": { + "branch": "rxswift4.0-swift4.0", + "revision": "7d344f6ca02683f6a52e61839ae0e01ecd4981eb", + "version": null + } + } + ] + }, + "version": 1 +} diff --git a/Package.swift b/Package.swift index d07e2b6..d024063 100644 --- a/Package.swift +++ b/Package.swift @@ -1,11 +1,18 @@ -// swift-tools-version:3.1 +// swift-tools-version:4.0 import PackageDescription let package = Package( name: "RxViewController", + products: [ + .library(name: "RxViewController", targets: ["RxViewController"]), + ], dependencies: [ - .Package(url: "https://github.com/devxoul/RxSwift.git", majorVersion: 3), - .Package(url: "https://github.com/devxoul/RxExpect.git", majorVersion: 0), + .package(url: "https://github.com/ReactiveX/RxSwift.git", .branch("rxswift4.0-swift4.0")), + .package(url: "https://github.com/devxoul/RxExpect.git", .branch("swift-4.0")), + ], + targets: [ + .target(name: "RxViewController", dependencies: ["RxSwift", "RxCocoa"]), + .testTarget(name: "RxViewControllerTests", dependencies: ["RxViewController", "RxExpect"]), ] ) diff --git a/Sources/NSViewController+Rx.swift b/Sources/RxViewController/NSViewController+Rx.swift similarity index 100% rename from Sources/NSViewController+Rx.swift rename to Sources/RxViewController/NSViewController+Rx.swift diff --git a/Sources/UIViewController+Rx.swift b/Sources/RxViewController/UIViewController+Rx.swift similarity index 100% rename from Sources/UIViewController+Rx.swift rename to Sources/RxViewController/UIViewController+Rx.swift From ed8db664ed42cca7df05c99ac597bf5c71e2cc7b Mon Sep 17 00:00:00 2001 From: Suyeol Jeon Date: Mon, 25 Sep 2017 19:13:03 +0900 Subject: [PATCH 3/9] Update Swift version in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e3a9776..d9837c9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # RxViewController -![Swift](https://img.shields.io/badge/Swift-3.1-orange.svg) +![Swift](https://img.shields.io/badge/Swift-4.0-orange.svg) [![CocoaPods](http://img.shields.io/cocoapods/v/RxViewController.svg)](https://cocoapods.org/pods/RxViewController) [![Build Status](https://travis-ci.org/devxoul/RxViewController.svg?branch=master)](https://travis-ci.org/devxoul/RxViewController) [![codecov](https://img.shields.io/codecov/c/github/devxoul/RxViewController.svg)](https://codecov.io/gh/devxoul/RxViewController) From 2c567ef15a961c9a89078e959d9b7ccf6bf2a661 Mon Sep 17 00:00:00 2001 From: Suyeol Jeon Date: Mon, 25 Sep 2017 19:13:11 +0900 Subject: [PATCH 4/9] Update .travis.yml to Xcode 9 --- .travis.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 209bd33..6fc299b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,15 @@ -osx_image: xcode8.3 +osx_image: xcode9 language: objective-c sudo: required env: global: - PROJECT="RxViewController.xcodeproj" - - SCHEME="RxViewController" - - IOS_SDK="iphonesimulator10.3" - - MACOS_SDK="macosx10.12" - - TVOS_SDK="appletvsimulator10.2" + - SCHEME="RxViewController-Package" + - IOS_SDK="iphonesimulator11.0" + - MACOS_SDK="macosx10.13" + - TVOS_SDK="appletvsimulator11.0" matrix: - - SDK="$IOS_SDK" DESTINATION="platform=iOS Simulator,name=iPhone 7,OS=10.3.1" + - SDK="$IOS_SDK" DESTINATION="platform=iOS Simulator,name=iPhone 8,OS=11.0" - SDK="$MACOS_SDK" DESTINATION="arch=x86_64" install: @@ -31,4 +31,4 @@ script: CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty -c after_success: - - bash <(curl -s https://codecov.io/bash) -J 'RxViewController' -X xcodeplist + - bash <(curl -s https://codecov.io/bash) -X xcodeplist -J 'RxViewController' From b32c9aec43903ce14b8f1cb3670a5974d9e12eda Mon Sep 17 00:00:00 2001 From: Suyeol Jeon Date: Tue, 26 Sep 2017 03:28:29 +0900 Subject: [PATCH 5/9] Update tests --- .../NSViewControllerTests.swift | 105 +++++------ .../UIViewControllerTests.swift | 168 ++++++++---------- 2 files changed, 124 insertions(+), 149 deletions(-) diff --git a/Tests/RxViewControllerTests/NSViewControllerTests.swift b/Tests/RxViewControllerTests/NSViewControllerTests.swift index 9f6fe02..41e9e95 100644 --- a/Tests/RxViewControllerTests/NSViewControllerTests.swift +++ b/Tests/RxViewControllerTests/NSViewControllerTests.swift @@ -3,90 +3,77 @@ import AppKit import XCTest import RxExpect -import RxTest - import RxViewController +import RxTest final class NSViewControllerTests: XCTestCase { func testViewDidLoad() { - RxExpect { test in - let viewController = NSViewController() - test.assert(viewController.rx.viewDidLoad).filterNext().isEmpty() - } - RxExpect { test in - let viewController = NSViewController() - test.scheduler.scheduleAt(0) { viewController.viewDidLoad() } - test.assert(viewController.rx.viewDidLoad).filterNext().count(1) + let test = RxExpect() + let viewController = NSViewController() + test.scheduler.scheduleAt(100) { viewController.viewDidLoad() } + test.assert(viewController.rx.viewDidLoad) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) } } func testViewWillAppear() { - RxExpect { test in - let viewController = NSViewController() - test.assert(viewController.rx.viewWillAppear).filterNext().isEmpty() - } - RxExpect { test in - let viewController = NSViewController() - test.scheduler.scheduleAt(0) { viewController.viewWillAppear() } - test.assert(viewController.rx.viewWillAppear).filterNext().count(1) + let test = RxExpect() + let viewController = NSViewController() + test.scheduler.scheduleAt(100) { viewController.viewWillAppear() } + test.assert(viewController.rx.viewWillAppear) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) } } + func testViewDidAppear() { - RxExpect { test in - let viewController = NSViewController() - test.assert(viewController.rx.viewDidAppear).filterNext().isEmpty() - } - RxExpect { test in - let viewController = NSViewController() - test.scheduler.scheduleAt(0) { viewController.viewDidAppear() } - test.assert(viewController.rx.viewDidAppear).filterNext().count(1) + let test = RxExpect() + let viewController = NSViewController() + test.scheduler.scheduleAt(100) { viewController.viewDidAppear() } + test.assert(viewController.rx.viewDidAppear) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) } } func testViewWillDisappear() { - RxExpect { test in - let viewController = NSViewController() - test.assert(viewController.rx.viewWillDisappear).filterNext().isEmpty() - } - RxExpect { test in - let viewController = NSViewController() - test.scheduler.scheduleAt(0) { viewController.viewWillDisappear() } - test.assert(viewController.rx.viewWillDisappear).filterNext().count(1) + let test = RxExpect() + let viewController = NSViewController() + test.scheduler.scheduleAt(100) { viewController.viewWillDisappear() } + test.assert(viewController.rx.viewWillDisappear) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) } } + func testViewDidDisappear() { - RxExpect { test in - let viewController = NSViewController() - test.assert(viewController.rx.viewDidDisappear).filterNext().isEmpty() - } - RxExpect { test in - let viewController = NSViewController() - test.scheduler.scheduleAt(0) { viewController.viewDidDisappear() } - test.assert(viewController.rx.viewDidDisappear).filterNext().count(1) + let test = RxExpect() + let viewController = NSViewController() + test.scheduler.scheduleAt(100) { viewController.viewDidDisappear() } + test.assert(viewController.rx.viewDidDisappear) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) } } - func testViewWillLayout() { - RxExpect { test in - let viewController = NSViewController() - test.assert(viewController.rx.viewWillLayout).filterNext().isEmpty() - } - RxExpect { test in - let viewController = NSViewController() - test.scheduler.scheduleAt(0) { viewController.viewWillLayout() } - test.assert(viewController.rx.viewWillLayout).filterNext().count(1) + let test = RxExpect() + let viewController = NSViewController() + test.scheduler.scheduleAt(100) { viewController.viewWillLayout() } + test.assert(viewController.rx.viewWillLayout) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) } } + func testViewDidLayout() { - RxExpect { test in - let viewController = NSViewController() - test.assert(viewController.rx.viewDidLayout).filterNext().isEmpty() - } - RxExpect { test in - let viewController = NSViewController() - test.scheduler.scheduleAt(0) { viewController.viewDidLayout() } - test.assert(viewController.rx.viewDidLayout).filterNext().count(1) + let test = RxExpect() + let viewController = NSViewController() + test.scheduler.scheduleAt(100) { viewController.viewDidLayout() } + test.assert(viewController.rx.viewDidLayout) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) } } } diff --git a/Tests/RxViewControllerTests/UIViewControllerTests.swift b/Tests/RxViewControllerTests/UIViewControllerTests.swift index 9b17878..1430387 100644 --- a/Tests/RxViewControllerTests/UIViewControllerTests.swift +++ b/Tests/RxViewControllerTests/UIViewControllerTests.swift @@ -3,133 +3,121 @@ import UIKit import XCTest import RxExpect -import RxTest - import RxViewController +import RxTest final class UIViewControllerTests: XCTestCase { func testViewDidLoad() { - RxExpect { test in - let viewController = UIViewController() - test.assert(viewController.rx.viewDidLoad).filterNext().isEmpty() - } - RxExpect { test in - let viewController = UIViewController() - test.scheduler.scheduleAt(0) { viewController.viewDidLoad() } - test.assert(viewController.rx.viewDidLoad).filterNext().count(1) + let test = RxExpect() + let viewController = UIViewController() + test.scheduler.scheduleAt(100) { viewController.viewDidLoad() } + test.assert(viewController.rx.viewDidLoad) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) } } func testViewWillAppear() { - RxExpect { test in - let viewController = UIViewController() - test.assert(viewController.rx.viewWillAppear).filterNext().isEmpty() - } - RxExpect { test in - let viewController = UIViewController() - test.scheduler.scheduleAt(0) { viewController.viewWillAppear(true) } - test.scheduler.scheduleAt(0) { viewController.viewWillAppear(false) } - test.assert(viewController.rx.viewWillAppear).filterNext().equal([true, false]) + let test = RxExpect() + let viewController = UIViewController() + test.scheduler.scheduleAt(100) { viewController.viewWillAppear(false) } + test.assert(viewController.rx.viewWillAppear) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.at(100...).filter(.next).first?.value.element, false) } } + func testViewDidAppear() { - RxExpect { test in - let viewController = UIViewController() - test.assert(viewController.rx.viewDidAppear).filterNext().isEmpty() - } - RxExpect { test in - let viewController = UIViewController() - test.scheduler.scheduleAt(0) { viewController.viewDidAppear(true) } - test.scheduler.scheduleAt(0) { viewController.viewDidAppear(false) } - test.assert(viewController.rx.viewDidAppear).filterNext().equal([true, false]) + let test = RxExpect() + let viewController = UIViewController() + test.scheduler.scheduleAt(100) { viewController.viewDidAppear(false) } + test.assert(viewController.rx.viewDidAppear) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.at(100...).filter(.next).first?.value.element, false) } } func testViewWillDisappear() { - RxExpect { test in - let viewController = UIViewController() - test.assert(viewController.rx.viewWillDisappear).filterNext().isEmpty() - } - RxExpect { test in - let viewController = UIViewController() - test.scheduler.scheduleAt(0) { viewController.viewWillDisappear(true) } - test.scheduler.scheduleAt(0) { viewController.viewWillDisappear(false) } - test.assert(viewController.rx.viewWillDisappear).filterNext().equal([true, false]) + let test = RxExpect() + let viewController = UIViewController() + test.scheduler.scheduleAt(100) { viewController.viewWillDisappear(false) } + test.assert(viewController.rx.viewWillDisappear) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.at(100...).filter(.next).first?.value.element, false) } } + func testViewDidDisappear() { - RxExpect { test in - let viewController = UIViewController() - test.assert(viewController.rx.viewDidDisappear).filterNext().isEmpty() - } - RxExpect { test in - let viewController = UIViewController() - test.scheduler.scheduleAt(0) { viewController.viewDidDisappear(true) } - test.scheduler.scheduleAt(0) { viewController.viewDidDisappear(false) } - test.assert(viewController.rx.viewDidDisappear).filterNext().equal([true, false]) + let test = RxExpect() + let viewController = UIViewController() + test.scheduler.scheduleAt(100) { viewController.viewDidDisappear(false) } + test.assert(viewController.rx.viewDidDisappear) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.at(100...).filter(.next).first?.value.element, false) } } func testViewWillLayoutSubviews() { - RxExpect { test in - let viewController = UIViewController() - test.assert(viewController.rx.viewWillLayoutSubviews).filterNext().isEmpty() - } - RxExpect { test in - let viewController = UIViewController() - test.scheduler.scheduleAt(0) { viewController.viewWillLayoutSubviews() } - test.assert(viewController.rx.viewWillLayoutSubviews).filterNext().count(1) + let test = RxExpect() + let viewController = UIViewController() + test.scheduler.scheduleAt(100) { viewController.viewWillLayoutSubviews() } + test.assert(viewController.rx.viewWillLayoutSubviews) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) } } + func testViewDidLayoutSubviews() { - RxExpect { test in - let viewController = UIViewController() - test.assert(viewController.rx.viewDidLayoutSubviews).filterNext().isEmpty() - } - RxExpect { test in - let viewController = UIViewController() - test.scheduler.scheduleAt(0) { viewController.viewDidLayoutSubviews() } - test.assert(viewController.rx.viewDidLayoutSubviews).filterNext().count(1) + let test = RxExpect() + let viewController = UIViewController() + test.scheduler.scheduleAt(100) { viewController.viewDidLayoutSubviews() } + test.assert(viewController.rx.viewDidLayoutSubviews) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) } } func testWillMoveToParentViewController() { - RxExpect { test in - let viewController = UIViewController() - test.assert(viewController.rx.willMoveToParentViewController).filterNext().isEmpty() - } - RxExpect { test in - let viewController = UIViewController() - let parentViewController = UIViewController() - test.scheduler.scheduleAt(0) { viewController.willMove(toParentViewController: parentViewController) } - test.scheduler.scheduleAt(0) { viewController.willMove(toParentViewController: nil) } - test.assert(viewController.rx.willMoveToParentViewController).filterNext().equal([parentViewController, nil]) { $0 === $1 } + let test = RxExpect() + let viewController = UIViewController() + let parentViewController = UIViewController() + test.scheduler.scheduleAt(100) { viewController.willMove(toParentViewController: parentViewController) } + test.scheduler.scheduleAt(200) { viewController.willMove(toParentViewController: nil) } + test.assert(viewController.rx.willMoveToParentViewController) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 2) + XCTAssertEqual(events.at(100...).filter(.next).first?.value.element ?? nil, parentViewController) + XCTAssertEqual(events.at(200...).filter(.next).first?.value.element ?? nil, nil) } } + func testDidMoveToParentViewController() { - RxExpect { test in - let viewController = UIViewController() - test.assert(viewController.rx.didMoveToParentViewController).filterNext().isEmpty() - } - RxExpect { test in - let viewController = UIViewController() - let parentViewController = UIViewController() - test.scheduler.scheduleAt(0) { viewController.didMove(toParentViewController: parentViewController) } - test.scheduler.scheduleAt(0) { viewController.didMove(toParentViewController: nil) } - test.assert(viewController.rx.didMoveToParentViewController).filterNext().equal([parentViewController, nil]) { $0 === $1 } + let test = RxExpect() + let viewController = UIViewController() + let parentViewController = UIViewController() + test.scheduler.scheduleAt(100) { viewController.didMove(toParentViewController: parentViewController) } + test.scheduler.scheduleAt(200) { viewController.didMove(toParentViewController: nil) } + test.assert(viewController.rx.didMoveToParentViewController) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 2) + XCTAssertEqual(events.at(100...).filter(.next).first?.value.element ?? nil, parentViewController) + XCTAssertEqual(events.at(200...).filter(.next).first?.value.element ?? nil, nil) } } func testDidReceiveMemoryWarning() { - RxExpect { test in - let viewController = UIViewController() - test.assert(viewController.rx.didReceiveMemoryWarning).filterNext().isEmpty() - } - RxExpect { test in - let viewController = UIViewController() - test.scheduler.scheduleAt(0) { viewController.didReceiveMemoryWarning() } - test.assert(viewController.rx.didReceiveMemoryWarning).filterNext().count(1) + let test = RxExpect() + let viewController = UIViewController() + test.scheduler.scheduleAt(100) { viewController.didReceiveMemoryWarning() } + test.assert(viewController.rx.didReceiveMemoryWarning) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).count, 1) } } } #endif + From b240cfb1d2c87b484ff5e731e4eaa3e61b2afc24 Mon Sep 17 00:00:00 2001 From: Thibault Wittemberg Date: Sun, 8 Oct 2017 12:30:19 -0400 Subject: [PATCH 6/9] Add new observables for visible and dismissed states We can now be triggered when a UIViewController: - has a displayed state change (visible or not) - is dismissing --- .../UIViewController+Rx.swift | 15 ++++++++++++ .../UIViewControllerTests.swift | 24 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Sources/RxViewController/UIViewController+Rx.swift b/Sources/RxViewController/UIViewController+Rx.swift index c2e4f42..bb2daeb 100644 --- a/Sources/RxViewController/UIViewController+Rx.swift +++ b/Sources/RxViewController/UIViewController+Rx.swift @@ -50,5 +50,20 @@ public extension Reactive where Base: UIViewController { let source = self.methodInvoked(#selector(Base.didReceiveMemoryWarning)).map { _ in } return ControlEvent(events: source) } + + /// Rx observable, triggered when the ViewController appearance state changes (true if the View is being displayed, false otherwise) + public var isVisible: Observable { + let viewDidAppearObservable = self.base.rx.viewDidAppear.map { _ in true } + let viewWillDisappearObservable = self.base.rx.viewWillDisappear.map { _ in false } + return Observable.merge(viewDidAppearObservable, viewWillDisappearObservable) + } + + /// Rx observable, triggered when the ViewController is being dismissed + public var isDismissing: ControlEvent { + let source = self.sentMessage(#selector(Base.dismiss)).map { $0.first as? Bool ?? false } + return ControlEvent(events: source) + } + } #endif + diff --git a/Tests/RxViewControllerTests/UIViewControllerTests.swift b/Tests/RxViewControllerTests/UIViewControllerTests.swift index 1430387..78d4006 100644 --- a/Tests/RxViewControllerTests/UIViewControllerTests.swift +++ b/Tests/RxViewControllerTests/UIViewControllerTests.swift @@ -118,6 +118,30 @@ final class UIViewControllerTests: XCTestCase { XCTAssertEqual(events.at(100...).filter(.next).count, 1) } } + + func testIsVisible() { + let test = RxExpect() + let viewController = UIViewController() + test.scheduler.scheduleAt(100) { viewController.viewDidAppear(false) } + test.scheduler.scheduleAt(200) { viewController.viewWillDisappear(false) } + test.assert(viewController.rx.isVisible) { events in + XCTAssertEqual(events.at(..<100).filter(.next).count, 0) + XCTAssertEqual(events.at(100...).filter(.next).first?.value.element ?? false, true) + XCTAssertEqual(events.at(200...).filter(.next).first?.value.element ?? true, false) + } + } + + func testIsDismissing() { + let test = RxExpect() + let viewController = UIViewController() + test.scheduler.scheduleAt(100) { viewController.viewDidAppear(false) } + test.scheduler.scheduleAt(200) { viewController.dismiss(animated: false) } + test.assert(viewController.rx.isDismissing) { events in + XCTAssertEqual(events.at(..<200).filter(.next).count, 0) + XCTAssertEqual(events.at(200...).filter(.next).count, 1) + } + } + } #endif From 13ccba121ad0a8fae3df35ca6666ee572c05d5b4 Mon Sep 17 00:00:00 2001 From: Suyeol Jeon Date: Wed, 11 Oct 2017 13:59:43 +0900 Subject: [PATCH 7/9] Update RxSwift dependency to 4.0.0-rc.0 --- Package.resolved | 8 ++++---- Package.swift | 2 +- RxViewController.podspec | 8 ++------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Package.resolved b/Package.resolved index 72f88d9..d9a2aa2 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,7 +6,7 @@ "repositoryURL": "https://github.com/devxoul/RxExpect.git", "state": { "branch": "swift-4.0", - "revision": "b3726078bf37f699da9e7566b16c996e94e8d321", + "revision": "773771cfbc975c91da0fca319ec22642a72d58ba", "version": null } }, @@ -14,9 +14,9 @@ "package": "RxSwift", "repositoryURL": "https://github.com/ReactiveX/RxSwift.git", "state": { - "branch": "rxswift4.0-swift4.0", - "revision": "7d344f6ca02683f6a52e61839ae0e01ecd4981eb", - "version": null + "branch": null, + "revision": "61261f2ee97ace3e08713921dd9406669b9debee", + "version": "4.0.0-rc.0" } } ] diff --git a/Package.swift b/Package.swift index d024063..d5b202e 100644 --- a/Package.swift +++ b/Package.swift @@ -8,7 +8,7 @@ let package = Package( .library(name: "RxViewController", targets: ["RxViewController"]), ], dependencies: [ - .package(url: "https://github.com/ReactiveX/RxSwift.git", .branch("rxswift4.0-swift4.0")), + .package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "4.0.0-rc.0")), .package(url: "https://github.com/devxoul/RxExpect.git", .branch("swift-4.0")), ], targets: [ diff --git a/RxViewController.podspec b/RxViewController.podspec index 048a5d9..f937f50 100644 --- a/RxViewController.podspec +++ b/RxViewController.podspec @@ -9,13 +9,9 @@ Pod::Spec.new do |s| :tag => s.version.to_s } s.source_files = "Sources/*.swift" s.frameworks = "Foundation" - s.dependency "RxSwift", ">= 3.0.0" - s.dependency "RxCocoa", ">= 3.0.0" + s.dependency "RxSwift", ">= 4.0.0-rc.0" + s.dependency "RxCocoa", ">= 4.0.0-rc.0" s.ios.deployment_target = "8.0" s.osx.deployment_target = "10.11" - - s.pod_target_xcconfig = { - "SWIFT_VERSION" => "3.0" - } end From 0b5a9607be45ac9a353c096092a985cd955e9ead Mon Sep 17 00:00:00 2001 From: Suyeol Jeon Date: Thu, 19 Oct 2017 01:03:14 +0900 Subject: [PATCH 8/9] Update RxSwift dependency to 4.0.0 --- Package.resolved | 6 +++--- Package.swift | 2 +- RxViewController.podspec | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Package.resolved b/Package.resolved index d9a2aa2..441a0c9 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,9 +5,9 @@ "package": "RxExpect", "repositoryURL": "https://github.com/devxoul/RxExpect.git", "state": { - "branch": "swift-4.0", - "revision": "773771cfbc975c91da0fca319ec22642a72d58ba", - "version": null + "branch": null, + "revision": "cb1ba5377d8d8f9743e26ece6a4d42d11dbd3792", + "version": "1.0.0" } }, { diff --git a/Package.swift b/Package.swift index d5b202e..d39c06b 100644 --- a/Package.swift +++ b/Package.swift @@ -8,8 +8,8 @@ let package = Package( .library(name: "RxViewController", targets: ["RxViewController"]), ], dependencies: [ - .package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "4.0.0-rc.0")), .package(url: "https://github.com/devxoul/RxExpect.git", .branch("swift-4.0")), + .package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "4.0.0")), ], targets: [ .target(name: "RxViewController", dependencies: ["RxSwift", "RxCocoa"]), diff --git a/RxViewController.podspec b/RxViewController.podspec index f937f50..0cb7244 100644 --- a/RxViewController.podspec +++ b/RxViewController.podspec @@ -9,8 +9,8 @@ Pod::Spec.new do |s| :tag => s.version.to_s } s.source_files = "Sources/*.swift" s.frameworks = "Foundation" - s.dependency "RxSwift", ">= 4.0.0-rc.0" - s.dependency "RxCocoa", ">= 4.0.0-rc.0" + s.dependency "RxSwift", ">= 4.0.0" + s.dependency "RxCocoa", ">= 4.0.0" s.ios.deployment_target = "8.0" s.osx.deployment_target = "10.11" From 6aa288a8f17464d67bf1d6e13ca20dc15f79f1f3 Mon Sep 17 00:00:00 2001 From: Suyeol Jeon Date: Thu, 19 Oct 2017 01:03:25 +0900 Subject: [PATCH 9/9] Update RxExpect dependency to 1.0.0 --- Package.resolved | 4 +- Package.swift | 2 +- .../NSViewControllerTests.swift | 28 ++++---- .../UIViewControllerTests.swift | 66 +++++++++---------- 4 files changed, 50 insertions(+), 50 deletions(-) diff --git a/Package.resolved b/Package.resolved index 441a0c9..31da12a 100644 --- a/Package.resolved +++ b/Package.resolved @@ -15,8 +15,8 @@ "repositoryURL": "https://github.com/ReactiveX/RxSwift.git", "state": { "branch": null, - "revision": "61261f2ee97ace3e08713921dd9406669b9debee", - "version": "4.0.0-rc.0" + "revision": "12cccb171ad9038251af6883807f0290c1d75a5b", + "version": "4.0.0" } } ] diff --git a/Package.swift b/Package.swift index d39c06b..4bdc3a3 100644 --- a/Package.swift +++ b/Package.swift @@ -8,8 +8,8 @@ let package = Package( .library(name: "RxViewController", targets: ["RxViewController"]), ], dependencies: [ - .package(url: "https://github.com/devxoul/RxExpect.git", .branch("swift-4.0")), .package(url: "https://github.com/ReactiveX/RxSwift.git", .upToNextMajor(from: "4.0.0")), + .package(url: "https://github.com/devxoul/RxExpect.git", .upToNextMajor(from: "1.0.0")), ], targets: [ .target(name: "RxViewController", dependencies: ["RxSwift", "RxCocoa"]), diff --git a/Tests/RxViewControllerTests/NSViewControllerTests.swift b/Tests/RxViewControllerTests/NSViewControllerTests.swift index 41e9e95..fe37dfc 100644 --- a/Tests/RxViewControllerTests/NSViewControllerTests.swift +++ b/Tests/RxViewControllerTests/NSViewControllerTests.swift @@ -12,8 +12,8 @@ final class NSViewControllerTests: XCTestCase { let viewController = NSViewController() test.scheduler.scheduleAt(100) { viewController.viewDidLoad() } test.assert(viewController.rx.viewDidLoad) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) } } @@ -22,8 +22,8 @@ final class NSViewControllerTests: XCTestCase { let viewController = NSViewController() test.scheduler.scheduleAt(100) { viewController.viewWillAppear() } test.assert(viewController.rx.viewWillAppear) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) } } @@ -32,8 +32,8 @@ final class NSViewControllerTests: XCTestCase { let viewController = NSViewController() test.scheduler.scheduleAt(100) { viewController.viewDidAppear() } test.assert(viewController.rx.viewDidAppear) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) } } @@ -42,8 +42,8 @@ final class NSViewControllerTests: XCTestCase { let viewController = NSViewController() test.scheduler.scheduleAt(100) { viewController.viewWillDisappear() } test.assert(viewController.rx.viewWillDisappear) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) } } @@ -52,8 +52,8 @@ final class NSViewControllerTests: XCTestCase { let viewController = NSViewController() test.scheduler.scheduleAt(100) { viewController.viewDidDisappear() } test.assert(viewController.rx.viewDidDisappear) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) } } @@ -62,8 +62,8 @@ final class NSViewControllerTests: XCTestCase { let viewController = NSViewController() test.scheduler.scheduleAt(100) { viewController.viewWillLayout() } test.assert(viewController.rx.viewWillLayout) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) } } @@ -72,8 +72,8 @@ final class NSViewControllerTests: XCTestCase { let viewController = NSViewController() test.scheduler.scheduleAt(100) { viewController.viewDidLayout() } test.assert(viewController.rx.viewDidLayout) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) } } } diff --git a/Tests/RxViewControllerTests/UIViewControllerTests.swift b/Tests/RxViewControllerTests/UIViewControllerTests.swift index 78d4006..f858f03 100644 --- a/Tests/RxViewControllerTests/UIViewControllerTests.swift +++ b/Tests/RxViewControllerTests/UIViewControllerTests.swift @@ -12,8 +12,8 @@ final class UIViewControllerTests: XCTestCase { let viewController = UIViewController() test.scheduler.scheduleAt(100) { viewController.viewDidLoad() } test.assert(viewController.rx.viewDidLoad) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) } } @@ -22,9 +22,9 @@ final class UIViewControllerTests: XCTestCase { let viewController = UIViewController() test.scheduler.scheduleAt(100) { viewController.viewWillAppear(false) } test.assert(viewController.rx.viewWillAppear) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) - XCTAssertEqual(events.at(100...).filter(.next).first?.value.element, false) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(100...).filter(.next).first?.value.element, false) } } @@ -33,9 +33,9 @@ final class UIViewControllerTests: XCTestCase { let viewController = UIViewController() test.scheduler.scheduleAt(100) { viewController.viewDidAppear(false) } test.assert(viewController.rx.viewDidAppear) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) - XCTAssertEqual(events.at(100...).filter(.next).first?.value.element, false) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(100...).filter(.next).first?.value.element, false) } } @@ -44,9 +44,9 @@ final class UIViewControllerTests: XCTestCase { let viewController = UIViewController() test.scheduler.scheduleAt(100) { viewController.viewWillDisappear(false) } test.assert(viewController.rx.viewWillDisappear) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) - XCTAssertEqual(events.at(100...).filter(.next).first?.value.element, false) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(100...).filter(.next).first?.value.element, false) } } @@ -55,9 +55,9 @@ final class UIViewControllerTests: XCTestCase { let viewController = UIViewController() test.scheduler.scheduleAt(100) { viewController.viewDidDisappear(false) } test.assert(viewController.rx.viewDidDisappear) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) - XCTAssertEqual(events.at(100...).filter(.next).first?.value.element, false) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(100...).filter(.next).first?.value.element, false) } } @@ -66,8 +66,8 @@ final class UIViewControllerTests: XCTestCase { let viewController = UIViewController() test.scheduler.scheduleAt(100) { viewController.viewWillLayoutSubviews() } test.assert(viewController.rx.viewWillLayoutSubviews) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) } } @@ -76,8 +76,8 @@ final class UIViewControllerTests: XCTestCase { let viewController = UIViewController() test.scheduler.scheduleAt(100) { viewController.viewDidLayoutSubviews() } test.assert(viewController.rx.viewDidLayoutSubviews) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) } } @@ -88,10 +88,10 @@ final class UIViewControllerTests: XCTestCase { test.scheduler.scheduleAt(100) { viewController.willMove(toParentViewController: parentViewController) } test.scheduler.scheduleAt(200) { viewController.willMove(toParentViewController: nil) } test.assert(viewController.rx.willMoveToParentViewController) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 2) - XCTAssertEqual(events.at(100...).filter(.next).first?.value.element ?? nil, parentViewController) - XCTAssertEqual(events.at(200...).filter(.next).first?.value.element ?? nil, nil) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 2) + XCTAssertEqual(events.in(100...).filter(.next).first?.value.element ?? nil, parentViewController) + XCTAssertEqual(events.in(200...).filter(.next).first?.value.element ?? nil, nil) } } @@ -102,10 +102,10 @@ final class UIViewControllerTests: XCTestCase { test.scheduler.scheduleAt(100) { viewController.didMove(toParentViewController: parentViewController) } test.scheduler.scheduleAt(200) { viewController.didMove(toParentViewController: nil) } test.assert(viewController.rx.didMoveToParentViewController) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 2) - XCTAssertEqual(events.at(100...).filter(.next).first?.value.element ?? nil, parentViewController) - XCTAssertEqual(events.at(200...).filter(.next).first?.value.element ?? nil, nil) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 2) + XCTAssertEqual(events.in(100...).filter(.next).first?.value.element ?? nil, parentViewController) + XCTAssertEqual(events.in(200...).filter(.next).first?.value.element ?? nil, nil) } } @@ -114,8 +114,8 @@ final class UIViewControllerTests: XCTestCase { let viewController = UIViewController() test.scheduler.scheduleAt(100) { viewController.didReceiveMemoryWarning() } test.assert(viewController.rx.didReceiveMemoryWarning) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).count, 1) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).count, 1) } } @@ -125,9 +125,9 @@ final class UIViewControllerTests: XCTestCase { test.scheduler.scheduleAt(100) { viewController.viewDidAppear(false) } test.scheduler.scheduleAt(200) { viewController.viewWillDisappear(false) } test.assert(viewController.rx.isVisible) { events in - XCTAssertEqual(events.at(..<100).filter(.next).count, 0) - XCTAssertEqual(events.at(100...).filter(.next).first?.value.element ?? false, true) - XCTAssertEqual(events.at(200...).filter(.next).first?.value.element ?? true, false) + XCTAssertEqual(events.in(..<100).filter(.next).count, 0) + XCTAssertEqual(events.in(100...).filter(.next).first?.value.element ?? false, true) + XCTAssertEqual(events.in(200...).filter(.next).first?.value.element ?? true, false) } } @@ -137,8 +137,8 @@ final class UIViewControllerTests: XCTestCase { test.scheduler.scheduleAt(100) { viewController.viewDidAppear(false) } test.scheduler.scheduleAt(200) { viewController.dismiss(animated: false) } test.assert(viewController.rx.isDismissing) { events in - XCTAssertEqual(events.at(..<200).filter(.next).count, 0) - XCTAssertEqual(events.at(200...).filter(.next).count, 1) + XCTAssertEqual(events.in(..<200).filter(.next).count, 0) + XCTAssertEqual(events.in(200...).filter(.next).count, 1) } }