From 343bb614411bcf49352e3d25d1e25874b61b6de4 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Sat, 6 Apr 2019 15:22:36 -0300 Subject: [PATCH 01/12] Upating dependencies to Rx 4.5.0 --- Action.podspec | 4 ++-- Package.resolved | 4 ++-- Package.swift | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Action.podspec b/Action.podspec index 7e21b46d..87fb2c42 100644 --- a/Action.podspec +++ b/Action.podspec @@ -20,8 +20,8 @@ Pod::Spec.new do |s| s.source_files = "Sources/**/*.{swift}" s.frameworks = "Foundation" - s.dependency "RxSwift", "~> 4.0" - s.dependency "RxCocoa", "~> 4.0" + s.dependency "RxSwift", "~> 4.5.0" + s.dependency "RxCocoa", "~> 4.5.0" s.watchos.exclude_files = "Control+Action.swift", "Button+Action.swift", "UIBarButtonItem+Action.swift", "UIAlertAction+Action.swift" s.osx.exclude_files = "UIBarButtonItem+Action.swift", "UIAlertAction+Action.swift" diff --git a/Package.resolved b/Package.resolved index b77b1084..4f553d3c 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/ReactiveX/RxSwift.git", "state": { "branch": null, - "revision": "12cccb171ad9038251af6883807f0290c1d75a5b", - "version": "4.0.0" + "revision": "cce95dd704bc08cd3d69c087a05a6fc3118e2722", + "version": "4.5.0" } } ] diff --git a/Package.swift b/Package.swift index fbef694a..502b22a0 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ let package = Package( targets: ["Action"]), ], dependencies: [ - .package(url: "https://github.com/ReactiveX/RxSwift.git", from: "4.0.0") + .package(url: "https://github.com/ReactiveX/RxSwift.git", .exact("4.5.0")) ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. From facd1821089738f5ffc2d60a00ce7920a851851d Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Sun, 7 Apr 2019 14:09:48 -0300 Subject: [PATCH 02/12] Reverting version. --- Action.podspec | 4 ++-- Package.resolved | 4 ++-- Package.swift | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Action.podspec b/Action.podspec index 87fb2c42..41a195a4 100644 --- a/Action.podspec +++ b/Action.podspec @@ -20,8 +20,8 @@ Pod::Spec.new do |s| s.source_files = "Sources/**/*.{swift}" s.frameworks = "Foundation" - s.dependency "RxSwift", "~> 4.5.0" - s.dependency "RxCocoa", "~> 4.5.0" + s.dependency "RxSwift", "~> 4.0.0" + s.dependency "RxCocoa", "~> 4.0.0" s.watchos.exclude_files = "Control+Action.swift", "Button+Action.swift", "UIBarButtonItem+Action.swift", "UIAlertAction+Action.swift" s.osx.exclude_files = "UIBarButtonItem+Action.swift", "UIAlertAction+Action.swift" diff --git a/Package.resolved b/Package.resolved index 4f553d3c..b77b1084 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/ReactiveX/RxSwift.git", "state": { "branch": null, - "revision": "cce95dd704bc08cd3d69c087a05a6fc3118e2722", - "version": "4.5.0" + "revision": "12cccb171ad9038251af6883807f0290c1d75a5b", + "version": "4.0.0" } } ] diff --git a/Package.swift b/Package.swift index 502b22a0..3ecd8269 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ let package = Package( targets: ["Action"]), ], dependencies: [ - .package(url: "https://github.com/ReactiveX/RxSwift.git", .exact("4.5.0")) + .package(url: "https://github.com/ReactiveX/RxSwift.git", .exact("4.0.0")) ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. From 562e35625bb260fba52628e35abc5d5215a36a61 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Sun, 7 Apr 2019 14:45:41 -0300 Subject: [PATCH 03/12] From 4.0.0 on package --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 3ecd8269..fbef694a 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ let package = Package( targets: ["Action"]), ], dependencies: [ - .package(url: "https://github.com/ReactiveX/RxSwift.git", .exact("4.0.0")) + .package(url: "https://github.com/ReactiveX/RxSwift.git", from: "4.0.0") ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. From acf36f7c1cf2e8cd50b3c340f4041521e08bed46 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 10 Apr 2019 12:12:45 -0300 Subject: [PATCH 04/12] Apply suggestions from code review --- Action.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Action.podspec b/Action.podspec index 41a195a4..7e21b46d 100644 --- a/Action.podspec +++ b/Action.podspec @@ -20,8 +20,8 @@ Pod::Spec.new do |s| s.source_files = "Sources/**/*.{swift}" s.frameworks = "Foundation" - s.dependency "RxSwift", "~> 4.0.0" - s.dependency "RxCocoa", "~> 4.0.0" + s.dependency "RxSwift", "~> 4.0" + s.dependency "RxCocoa", "~> 4.0" s.watchos.exclude_files = "Control+Action.swift", "Button+Action.swift", "UIBarButtonItem+Action.swift", "UIAlertAction+Action.swift" s.osx.exclude_files = "UIBarButtonItem+Action.swift", "UIAlertAction+Action.swift" From 15033174428ba09043b2a628585489da5319fc92 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 1 May 2019 10:49:48 -0300 Subject: [PATCH 05/12] Updating to Rx 5.0 --- .swift-version | 2 +- Action.podspec | 4 ++-- Package.resolved | 4 ++-- Package.swift | 2 +- Sources/Action/Action.swift | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.swift-version b/.swift-version index bf77d549..6e636605 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.2 +5.0 \ No newline at end of file diff --git a/Action.podspec b/Action.podspec index 7e21b46d..3cb08116 100644 --- a/Action.podspec +++ b/Action.podspec @@ -20,8 +20,8 @@ Pod::Spec.new do |s| s.source_files = "Sources/**/*.{swift}" s.frameworks = "Foundation" - s.dependency "RxSwift", "~> 4.0" - s.dependency "RxCocoa", "~> 4.0" + s.dependency "RxSwift", "~> 5.0.0" + s.dependency "RxCocoa", "~> 5.0.0" s.watchos.exclude_files = "Control+Action.swift", "Button+Action.swift", "UIBarButtonItem+Action.swift", "UIAlertAction+Action.swift" s.osx.exclude_files = "UIBarButtonItem+Action.swift", "UIAlertAction+Action.swift" diff --git a/Package.resolved b/Package.resolved index b77b1084..e3afef80 100644 --- a/Package.resolved +++ b/Package.resolved @@ -6,8 +6,8 @@ "repositoryURL": "https://github.com/ReactiveX/RxSwift.git", "state": { "branch": null, - "revision": "12cccb171ad9038251af6883807f0290c1d75a5b", - "version": "4.0.0" + "revision": "b3e888b4972d9bc76495dd74d30a8c7fad4b9395", + "version": "5.0.1" } } ] diff --git a/Package.swift b/Package.swift index fbef694a..06e59def 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ let package = Package( targets: ["Action"]), ], dependencies: [ - .package(url: "https://github.com/ReactiveX/RxSwift.git", from: "4.0.0") + .package(url: "https://github.com/ReactiveX/RxSwift.git", from: "5.0.0") ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Sources/Action/Action.swift b/Sources/Action/Action.swift index 0dac422b..c4917508 100644 --- a/Sources/Action/Action.swift +++ b/Sources/Action/Action.swift @@ -54,7 +54,7 @@ public final class Action { public convenience init( enabledIf: Observable = Observable.just(true), workFactory: @escaping (Input) -> O - ) where O.E == Element { + ) where O.Element == Element { self.init(enabledIf: enabledIf) { workFactory($0).asObservable() } From 0115797a567bbaac796cb5024e901c6ff3f2d658 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 1 May 2019 12:21:59 -0300 Subject: [PATCH 06/12] Updating to Rx 5.0 and fixing deprecated warnings. --- Cartfile | 2 +- Cartfile.resolved | 2 +- Tests/ActionTests/ActionTests.swift | 142 ++++++++++++++-------------- 3 files changed, 73 insertions(+), 73 deletions(-) diff --git a/Cartfile b/Cartfile index 0fb6d5b8..43e186b7 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "ReactiveX/RxSwift" ~> 4.4.2 +github "ReactiveX/RxSwift" ~> 5.0.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 79eb0d72..851ad793 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,3 @@ github "Quick/Nimble" "v8.0.1" github "Quick/Quick" "v2.1.0" -github "ReactiveX/RxSwift" "4.5.0" +github "ReactiveX/RxSwift" "5.0.1" \ No newline at end of file diff --git a/Tests/ActionTests/ActionTests.swift b/Tests/ActionTests/ActionTests.swift index fba1c2af..82502d57 100644 --- a/Tests/ActionTests/ActionTests.swift +++ b/Tests/ActionTests/ActionTests.swift @@ -33,8 +33,8 @@ class ActionTests: QuickSpec { it("receives generated inputs") { scheduler.start() XCTAssertEqual(inputs.events, [ - next(10, "a"), - next(20, "b"), + Recorded.next(10, "a"), + Recorded.next(20, "b"), ]) } it("emits nothing on `elements`") { @@ -183,15 +183,15 @@ class ActionTests: QuickSpec { sharedExamples("send elements to elements observable") { it("work factory receives inputs") { XCTAssertEqual(inputs.events, [ - next(10, "a"), - next(20, "b"), + Recorded.next(10, "a"), + Recorded.next(20, "b"), ]) } it("elements observable receives generated elements") { XCTAssertEqual(elements.events, [ - next(10, "a"), - next(20, "b"), + Recorded.next(10, "a"), + Recorded.next(20, "b"), ]) } @@ -201,21 +201,21 @@ class ActionTests: QuickSpec { it("disabled until element returns") { XCTAssertEqual(enabled.events, [ - next(0, true), - next(10, false), - next(10, true), - next(20, false), - next(20, true), + Recorded.next(0, true), + Recorded.next(10, false), + Recorded.next(10, true), + Recorded.next(20, false), + Recorded.next(20, true), ]) } it("executing until element returns") { XCTAssertEqual(executing.events, [ - next(0, false), - next(10, true), - next(10, false), - next(20, true), - next(20, false), + Recorded.next(0, false), + Recorded.next(10, true), + Recorded.next(10, false), + Recorded.next(20, true), + Recorded.next(20, false), ]) } @@ -255,19 +255,19 @@ class ActionTests: QuickSpec { sharedExamples("send array elements to elements observable") { it("work factory receives inputs") { XCTAssertEqual(inputs.events, [ - next(10, "a"), - next(20, "b"), + Recorded.next(10, "a"), + Recorded.next(20, "b"), ]) } it("elements observable receives generated elements") { XCTAssertEqual(elements.events, [ - next(10, "a"), - next(10, "b"), - next(10, "c"), - next(20, "b"), - next(20, "c"), - next(20, "d"), + Recorded.next(10, "a"), + Recorded.next(10, "b"), + Recorded.next(10, "c"), + Recorded.next(20, "b"), + Recorded.next(20, "c"), + Recorded.next(20, "d"), ]) } @@ -277,21 +277,21 @@ class ActionTests: QuickSpec { it("disabled until element returns") { XCTAssertEqual(enabled.events, [ - next(0, true), - next(10, false), - next(10, true), - next(20, false), - next(20, true), + Recorded.next(0, true), + Recorded.next(10, false), + Recorded.next(10, true), + Recorded.next(20, false), + Recorded.next(20, true), ]) } it("executing until element returns") { XCTAssertEqual(executing.events, [ - next(0, false), - next(10, true), - next(10, false), - next(20, true), - next(20, false), + Recorded.next(0, false), + Recorded.next(10, true), + Recorded.next(10, false), + Recorded.next(20, true), + Recorded.next(20, false), ]) } @@ -339,8 +339,8 @@ class ActionTests: QuickSpec { sharedExamples("send errors to errors observable") { it("work factory receives inputs") { XCTAssertEqual(inputs.events, [ - next(10, "a"), - next(20, "b"), + Recorded.next(10, "a"), + Recorded.next(20, "b"), ]) } @@ -350,8 +350,8 @@ class ActionTests: QuickSpec { it("errors observable receives generated errors") { XCTAssertEqual(errors.events, [ - next(10, .underlyingError(TestError)), - next(20, .underlyingError(TestError)), + Recorded.next(10, .underlyingError(TestError)), + Recorded.next(20, .underlyingError(TestError)), ]) } @@ -368,21 +368,21 @@ class ActionTests: QuickSpec { it("disabled until error returns") { XCTAssertEqual(enabled.events, [ - next(0, true), - next(10, false), - next(10, true), - next(20, false), - next(20, true), + Recorded.next(0, true), + Recorded.next(10, false), + Recorded.next(10, true), + Recorded.next(20, false), + Recorded.next(20, true), ]) } it("executing until error returns") { XCTAssertEqual(executing.events, [ - next(0, false), - next(10, true), - next(10, false), - next(20, true), - next(20, false), + Recorded.next(0, false), + Recorded.next(10, true), + Recorded.next(10, false), + Recorded.next(20, true), + Recorded.next(20, false), ]) } @@ -430,8 +430,8 @@ class ActionTests: QuickSpec { it("errors observable receives generated errors") { XCTAssertEqual(errors.events, [ - next(10, .notEnabled), - next(20, .notEnabled), + Recorded.next(10, .notEnabled), + Recorded.next(20, .notEnabled), ]) } @@ -441,13 +441,13 @@ class ActionTests: QuickSpec { it("disabled") { XCTAssertEqual(enabled.events, [ - next(0, false), + Recorded.next(0, false), ]) } it("never be executing") { XCTAssertEqual(executing.events, [ - next(0, false), + Recorded.next(0, false), ]) } @@ -522,10 +522,10 @@ class ActionTests: QuickSpec { it("element receives single value for each execution") { XCTAssertEqual(element.events, [ - next(10, "a"), - completed(10), - next(20, "b"), - completed(20), + Recorded.next(10, "a"), + Recorded.completed(10), + Recorded.next(20, "b"), + Recorded.completed(20), ]) } @@ -542,14 +542,14 @@ class ActionTests: QuickSpec { it("element receives 3 values for each execution") { XCTAssertEqual(element.events, [ - next(10, "a"), - next(10, "a"), - next(10, "a"), - completed(10), - next(20, "b"), - next(20, "b"), - next(20, "b"), - completed(20), + Recorded.next(10, "a"), + Recorded.next(10, "a"), + Recorded.next(10, "a"), + Recorded.completed(10), + Recorded.next(20, "b"), + Recorded.next(20, "b"), + Recorded.next(20, "b"), + Recorded.completed(20), ]) } @@ -566,8 +566,8 @@ class ActionTests: QuickSpec { it("element fails with underlyingError") { XCTAssertEqual(element.events, [ - error(10, ActionError.underlyingError(TestError)), - error(20, ActionError.underlyingError(TestError)), + Recorded.error(10, ActionError.underlyingError(TestError)), + Recorded.error(20, ActionError.underlyingError(TestError)), ]) } @@ -584,8 +584,8 @@ class ActionTests: QuickSpec { it("element fails with notEnabled") { XCTAssertEqual(element.events, [ - error(10, ActionError.notEnabled), - error(20, ActionError.notEnabled), + Recorded.error(10, ActionError.notEnabled), + Recorded.error(20, ActionError.notEnabled), ]) } @@ -632,14 +632,14 @@ class ActionTests: QuickSpec { it("first element receives single value") { XCTAssertEqual(element.events, [ - next(30, "a"), - completed(30), + Recorded.next(30, "a"), + Recorded.completed(30), ]) } it("second element fails with notEnabled error") { XCTAssertEqual(secondElement.events, [ - error(20, ActionError.notEnabled) + Recorded.error(20, ActionError.notEnabled) ]) } From 06d48da95980e8524b790435366e57718b5e82a3 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 1 May 2019 12:27:12 -0300 Subject: [PATCH 07/12] Swiftlint autocorrect on test directory. --- Tests/ActionTests/ActionTests.swift | 217 +++++++++++----------- Tests/iOS-Tests/AlertActionTests.swift | 12 +- Tests/iOS-Tests/BarButtonTests.swift | 50 ++--- Tests/iOS-Tests/BindToTests.swift | 39 ++-- Tests/iOS-Tests/ButtonTests.swift | 6 +- Tests/iOS-Tests/RefreshControlTests.swift | 19 +- Tests/macOS-Tests/BindToTests.swift | 18 +- Tests/macOS-Tests/NSButtonTests.swift | 65 ++++--- 8 files changed, 210 insertions(+), 216 deletions(-) diff --git a/Tests/ActionTests/ActionTests.swift b/Tests/ActionTests/ActionTests.swift index 82502d57..2bba9007 100644 --- a/Tests/ActionTests/ActionTests.swift +++ b/Tests/ActionTests/ActionTests.swift @@ -9,7 +9,7 @@ class ActionTests: QuickSpec { override func spec() { var scheduler: TestScheduler! var disposeBag: DisposeBag! - + beforeEach { scheduler = TestScheduler(initialClock: 0) disposeBag = DisposeBag() @@ -34,7 +34,7 @@ class ActionTests: QuickSpec { scheduler.start() XCTAssertEqual(inputs.events, [ Recorded.next(10, "a"), - Recorded.next(20, "b"), + Recorded.next(20, "b") ]) } it("emits nothing on `elements`") { @@ -117,7 +117,6 @@ class ActionTests: QuickSpec { XCTAssertEqual(executions.events.filter { $0.value.isStopEvent }.count, 0) } } - describe("action properties") { var inputs: TestableObserver! var elements: TestableObserver! @@ -126,7 +125,7 @@ class ActionTests: QuickSpec { var executing: TestableObserver! var executionObservables: TestableObserver>! var underlyingError: TestableObserver! - + beforeEach { inputs = scheduler.createObserver(String.self) elements = scheduler.createObserver(String.self) @@ -147,23 +146,23 @@ class ActionTests: QuickSpec { action.elements .bind(to: elements) .disposed(by: disposeBag) - + action.errors .bind(to: errors) .disposed(by: disposeBag) - + action.enabled .bind(to: enabled) .disposed(by: disposeBag) - + action.executing .bind(to: executing) .disposed(by: disposeBag) - + action.executionObservables .bind(to: executionObservables) .disposed(by: disposeBag) - + action.underlyingError .bind(to: underlyingError) .disposed(by: disposeBag) @@ -178,88 +177,88 @@ class ActionTests: QuickSpec { return action } - + describe("single element action") { sharedExamples("send elements to elements observable") { it("work factory receives inputs") { XCTAssertEqual(inputs.events, [ Recorded.next(10, "a"), - Recorded.next(20, "b"), + Recorded.next(20, "b") ]) } - + it("elements observable receives generated elements") { XCTAssertEqual(elements.events, [ Recorded.next(10, "a"), - Recorded.next(20, "b"), + Recorded.next(20, "b") ]) } - + it("errors observable receives nothing") { XCTAssertEqual(errors.events, []) } - + it("disabled until element returns") { XCTAssertEqual(enabled.events, [ Recorded.next(0, true), Recorded.next(10, false), Recorded.next(10, true), Recorded.next(20, false), - Recorded.next(20, true), + Recorded.next(20, true) ]) } - + it("executing until element returns") { XCTAssertEqual(executing.events, [ Recorded.next(0, false), Recorded.next(10, true), Recorded.next(10, false), Recorded.next(20, true), - Recorded.next(20, false), + Recorded.next(20, false) ]) } - + it("executes twice") { expect(executionObservables.events.count) == 2 } } - + var action: Action! - + beforeEach { action = buildAction { Observable.just($0) } } - + context("trigger via inputs subject") { beforeEach { scheduler.scheduleAt(10) { action.inputs.onNext("a") } scheduler.scheduleAt(20) { action.inputs.onNext("b") } scheduler.start() } - + itBehavesLike("send elements to elements observable") } - + context("trigger via execute() method") { beforeEach { scheduler.scheduleAt(10) { action.execute("a") } scheduler.scheduleAt(20) { action.execute("b") } scheduler.start() } - + itBehavesLike("send elements to elements observable") } } - + describe("multiple element action") { sharedExamples("send array elements to elements observable") { it("work factory receives inputs") { XCTAssertEqual(inputs.events, [ Recorded.next(10, "a"), - Recorded.next(20, "b"), + Recorded.next(20, "b") ]) } - + it("elements observable receives generated elements") { XCTAssertEqual(elements.events, [ Recorded.next(10, "a"), @@ -267,41 +266,41 @@ class ActionTests: QuickSpec { Recorded.next(10, "c"), Recorded.next(20, "b"), Recorded.next(20, "c"), - Recorded.next(20, "d"), + Recorded.next(20, "d") ]) } - + it("errors observable receives nothing") { XCTAssertEqual(errors.events, []) } - + it("disabled until element returns") { XCTAssertEqual(enabled.events, [ Recorded.next(0, true), Recorded.next(10, false), Recorded.next(10, true), Recorded.next(20, false), - Recorded.next(20, true), + Recorded.next(20, true) ]) } - + it("executing until element returns") { XCTAssertEqual(executing.events, [ Recorded.next(0, false), Recorded.next(10, true), Recorded.next(10, false), Recorded.next(20, true), - Recorded.next(20, false), + Recorded.next(20, false) ]) } - + it("executes twice") { expect(executionObservables.events.count) == 2 } } - + var action: Action! - + beforeEach { action = buildAction { input in // "a" -> ["a", "b", "c"] @@ -309,237 +308,237 @@ class ActionTests: QuickSpec { let strings = (baseValue..<(baseValue + 3)) .compactMap { UnicodeScalar($0) } .map { String($0) } - + return Observable.from(strings) } } - + context("trigger via inputs subject") { beforeEach { scheduler.scheduleAt(10) { action.inputs.onNext("a") } scheduler.scheduleAt(20) { action.inputs.onNext("b") } scheduler.start() } - + itBehavesLike("send array elements to elements observable") } - + context("trigger via execute() method") { beforeEach { scheduler.scheduleAt(10) { action.execute("a") } scheduler.scheduleAt(20) { action.execute("b") } scheduler.start() } - + itBehavesLike("send array elements to elements observable") } } - + describe("error action") { sharedExamples("send errors to errors observable") { it("work factory receives inputs") { XCTAssertEqual(inputs.events, [ Recorded.next(10, "a"), - Recorded.next(20, "b"), + Recorded.next(20, "b") ]) } - + it("elements observable receives nothing") { XCTAssertEqual(elements.events, []) } - + it("errors observable receives generated errors") { XCTAssertEqual(errors.events, [ Recorded.next(10, .underlyingError(TestError)), - Recorded.next(20, .underlyingError(TestError)), + Recorded.next(20, .underlyingError(TestError)) ]) } - + it("underlyingError observable receives 2 generated errors") { XCTAssertEqual(underlyingError.events.count, 2) } - + it("underlyingError observable receives generated errors") { let first = underlyingError.events[0].value.element as! String let second = underlyingError.events[1].value.element as! String XCTAssertEqual(first, TestError) XCTAssertEqual(second, TestError) } - + it("disabled until error returns") { XCTAssertEqual(enabled.events, [ Recorded.next(0, true), Recorded.next(10, false), Recorded.next(10, true), Recorded.next(20, false), - Recorded.next(20, true), + Recorded.next(20, true) ]) } - + it("executing until error returns") { XCTAssertEqual(executing.events, [ Recorded.next(0, false), Recorded.next(10, true), Recorded.next(10, false), Recorded.next(20, true), - Recorded.next(20, false), + Recorded.next(20, false) ]) } - + it("executes twice") { expect(executionObservables.events.count) == 2 } } - + var action: Action! - + beforeEach { action = buildAction { _ in Observable.error(TestError) } } - + context("trigger via inputs subject") { beforeEach { scheduler.scheduleAt(10) { action.inputs.onNext("a") } scheduler.scheduleAt(20) { action.inputs.onNext("b") } scheduler.start() } - + itBehavesLike("send errors to errors observable") } - + context("trigger via execute() method") { beforeEach { scheduler.scheduleAt(10) { action.execute("a") } scheduler.scheduleAt(20) { action.execute("b") } scheduler.start() } - + itBehavesLike("send errors to errors observable") } } - + describe("disabled action") { sharedExamples("send notEnabled errors to errors observable") { it("work factory receives nothing") { XCTAssertEqual(inputs.events, []) } - + it("elements observable receives nothing") { XCTAssertEqual(elements.events, []) } - + it("errors observable receives generated errors") { XCTAssertEqual(errors.events, [ Recorded.next(10, .notEnabled), - Recorded.next(20, .notEnabled), + Recorded.next(20, .notEnabled) ]) } - + it("underlyingError observable receives zero generated errors") { XCTAssertEqual(underlyingError.events.count, 0) } - + it("disabled") { XCTAssertEqual(enabled.events, [ - Recorded.next(0, false), + Recorded.next(0, false) ]) } - + it("never be executing") { XCTAssertEqual(executing.events, [ - Recorded.next(0, false), + Recorded.next(0, false) ]) } - + it("never executes") { expect(executionObservables.events).to(beEmpty()) } } - + var action: Action! - + beforeEach { action = buildAction(enabledIf: Observable.just(false)) { Observable.just($0) } } - + context("trigger via inputs subject") { beforeEach { scheduler.scheduleAt(10) { action.inputs.onNext("a") } scheduler.scheduleAt(20) { action.inputs.onNext("b") } scheduler.start() } - + itBehavesLike("send notEnabled errors to errors observable") } - + context("trigger via execute() method") { beforeEach { scheduler.scheduleAt(10) { action.execute("a") } scheduler.scheduleAt(20) { action.execute("b") } scheduler.start() } - + itBehavesLike("send notEnabled errors to errors observable") } } } - + describe("execute function return value") { var action: Action! var element: TestableObserver! var executionObservables: TestableObserver>! - + beforeEach { element = scheduler.createObserver(String.self) executionObservables = scheduler.createObserver(Observable.self) } - + func bindAndExecuteTwice(action: Action) { action.executionObservables .bind(to: executionObservables) .disposed(by: disposeBag) - + scheduler.scheduleAt(10) { action.execute("a") .bind(to: element) .disposed(by: disposeBag) } - + scheduler.scheduleAt(20) { action.execute("b") .bind(to: element) .disposed(by: disposeBag) } - + scheduler.start() } - + context("single element action") { beforeEach { action = Action { Observable.just($0) } bindAndExecuteTwice(action: action) } - + it("element receives single value for each execution") { XCTAssertEqual(element.events, [ Recorded.next(10, "a"), Recorded.completed(10), Recorded.next(20, "b"), - Recorded.completed(20), + Recorded.completed(20) ]) } - + it("executes twice") { expect(executionObservables.events.count) == 2 } } - + context("multiple element action") { beforeEach { action = Action { Observable.of($0, $0, $0) } bindAndExecuteTwice(action: action) } - + it("element receives 3 values for each execution") { XCTAssertEqual(element.events, [ Recorded.next(10, "a"), @@ -549,76 +548,76 @@ class ActionTests: QuickSpec { Recorded.next(20, "b"), Recorded.next(20, "b"), Recorded.next(20, "b"), - Recorded.completed(20), + Recorded.completed(20) ]) } - + it("executes twice") { expect(executionObservables.events.count) == 2 } } - + context("error action") { beforeEach { action = Action { _ in Observable.error(TestError) } bindAndExecuteTwice(action: action) } - + it("element fails with underlyingError") { XCTAssertEqual(element.events, [ Recorded.error(10, ActionError.underlyingError(TestError)), - Recorded.error(20, ActionError.underlyingError(TestError)), + Recorded.error(20, ActionError.underlyingError(TestError)) ]) } - + it("executes twice") { expect(executionObservables.events.count) == 2 } } - + context("disabled") { beforeEach { action = Action(enabledIf: Observable.just(false)) { Observable.just($0) } bindAndExecuteTwice(action: action) } - + it("element fails with notEnabled") { XCTAssertEqual(element.events, [ Recorded.error(10, ActionError.notEnabled), - Recorded.error(20, ActionError.notEnabled), + Recorded.error(20, ActionError.notEnabled) ]) } - + it("never executes") { expect(executionObservables.events).to(beEmpty()) } } - + context("execute while executing") { var secondElement: TestableObserver! var trigger: PublishSubject! - + beforeEach { secondElement = scheduler.createObserver(String.self) trigger = PublishSubject() action = Action { Observable.just($0).sample(trigger) } - + action.executionObservables .bind(to: executionObservables) .disposed(by: disposeBag) - + scheduler.scheduleAt(10) { action.execute("a") .bind(to: element) .disposed(by: disposeBag) } - + scheduler.scheduleAt(20) { action.execute("b") .bind(to: secondElement) .disposed(by: disposeBag) } - + scheduler.scheduleAt(30) { #if swift(>=3.2) trigger.onNext(()) @@ -626,23 +625,23 @@ class ActionTests: QuickSpec { trigger.onNext() #endif } - + scheduler.start() } - + it("first element receives single value") { XCTAssertEqual(element.events, [ Recorded.next(30, "a"), - Recorded.completed(30), + Recorded.completed(30) ]) } - + it("second element fails with notEnabled error") { XCTAssertEqual(secondElement.events, [ Recorded.error(20, ActionError.notEnabled) ]) } - + it("executes once") { expect(executionObservables.events.count) == 1 } diff --git a/Tests/iOS-Tests/AlertActionTests.swift b/Tests/iOS-Tests/AlertActionTests.swift index 88ef4884..c4b8ab47 100644 --- a/Tests/iOS-Tests/AlertActionTests.swift +++ b/Tests/iOS-Tests/AlertActionTests.swift @@ -57,17 +57,17 @@ class AlertActionTests: QuickSpec { expect(subject.isEnabled) == false } - + it("disposes of old action subscriptions when re-set") { var subject = UIAlertAction.Action("Hi", style: .default) - + var disposed = false autoreleasepool { let disposeBag = DisposeBag() - + let action = emptyAction() subject.rx.action = action - + action .elements .subscribe(onNext: nil, onError: nil, onCompleted: nil, onDisposed: { @@ -75,9 +75,9 @@ class AlertActionTests: QuickSpec { }) .disposed(by: disposeBag) } - + subject.rx.action = nil - + expect(disposed) == true } } diff --git a/Tests/iOS-Tests/BarButtonTests.swift b/Tests/iOS-Tests/BarButtonTests.swift index 6bb9c679..062d98d7 100644 --- a/Tests/iOS-Tests/BarButtonTests.swift +++ b/Tests/iOS-Tests/BarButtonTests.swift @@ -6,25 +6,25 @@ import Action class BarButtonTests: QuickSpec { override func spec() { - + it("is nil by default") { let subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil) expect(subject.rx.action).to( beNil() ) } - + it("respects setter") { var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil) - + let action = emptyAction() - + subject.rx.action = action - + expect(subject.rx.action) === action } - + it("disables the button while executing") { var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil) - + var observer: AnyObserver! let action = CocoaAction(workFactory: { _ in return Observable.create { (obsv) -> Disposable in @@ -32,28 +32,28 @@ class BarButtonTests: QuickSpec { return Disposables.create() } }) - + subject.rx.action = action - + action.execute() expect(subject.isEnabled).toEventually( beFalse() ) - + observer.onCompleted() expect(subject.isEnabled).toEventually( beTrue() ) } - + it("disables the button if the Action is disabled") { var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil) - + subject.rx.action = emptyAction(.just(false)) expect(subject.target).toEventuallyNot( beNil() ) - + expect(subject.isEnabled) == false } - + it("doesn't execute a disabled action when tapped") { var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil) - + var executed = false subject.rx.action = CocoaAction(enabledIf: .just(false), workFactory: { _ in executed = true @@ -61,13 +61,13 @@ class BarButtonTests: QuickSpec { }) _ = subject.target?.perform(subject.action, with: subject) - + expect(executed) == false } - + it("executes the action when tapped") { var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil) - + var executed = false let action = CocoaAction(workFactory: { _ in executed = true @@ -78,20 +78,20 @@ class BarButtonTests: QuickSpec { expect(subject.target).toEventuallyNot( beNil() ) _ = subject.target?.perform(subject.action, with: subject) - + expect(executed) == true } - + it("disposes of old action subscriptions when re-set") { var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil) - + var disposed = false autoreleasepool { let disposeBag = DisposeBag() - + let action = emptyAction() subject.rx.action = action - + action .elements .subscribe(onNext: nil, onError: nil, onCompleted: nil, onDisposed: { @@ -99,9 +99,9 @@ class BarButtonTests: QuickSpec { }) .disposed(by: disposeBag) } - + subject.rx.action = nil - + expect(disposed) == true } } diff --git a/Tests/iOS-Tests/BindToTests.swift b/Tests/iOS-Tests/BindToTests.swift index 552be95c..5134f1f0 100644 --- a/Tests/iOS-Tests/BindToTests.swift +++ b/Tests/iOS-Tests/BindToTests.swift @@ -40,12 +40,12 @@ class BindToTests: QuickSpec { button.rx.bind(to: action, input: "Hi there!") // Setting the action has an asynchronous effect of adding a target. expect(button.allTargets.count) == 1 - + button.test_executeTap() - + expect(called).toEventually( beTrue() ) } - + it("activates a generic control event") { var called = false let button = UIButton() @@ -56,12 +56,12 @@ class BindToTests: QuickSpec { button.rx.bind(to: action, controlEvent: button.rx.tap, inputTransform: { input in "\(input)" }) // Setting the action has an asynchronous effect of adding a target. expect(button.allTargets.count) == 1 - + button.test_executeTap() - + expect(called).toEventually( beTrue() ) } - + it("actives a UIBarButtonItem") { var called = false let item = UIBarButtonItem() @@ -70,9 +70,9 @@ class BindToTests: QuickSpec { return .empty() }) item.rx.bind(to: action, input: "Hi there!") - + _ = item.target!.perform(item.action!, with: item) - + expect(called).toEventually( beTrue() ) } it("actives a UIRefreshControl") { @@ -83,12 +83,12 @@ class BindToTests: QuickSpec { return .empty() }) item.rx.bind(to: action, input: "Hi there!") - + item.test_executeRefresh() - + expect(called).toEventually( beTrue() ) } - + describe("unbinding") { it("unbinds actions for UIButton") { let button = UIButton() @@ -99,13 +99,13 @@ class BindToTests: QuickSpec { button.rx.bind(to: action, input: "Hi there!") // Setting the action has an asynchronous effect of adding a target. expect(button.allTargets.count) == 1 - + button.rx.unbindAction() button.test_executeTap() - + expect(button.allTargets.count) == 0 } - + it("unbinds actions for UIRefreshControl") { let refreshControl = UIRefreshControl() let action = Action(workFactory: { _ in @@ -115,13 +115,13 @@ class BindToTests: QuickSpec { refreshControl.rx.bind(to: action, input: "Hi there!") // Setting the action has an asynchronous effect of adding a target. expect(refreshControl.allTargets.count) == 1 - + refreshControl.rx.unbindAction() refreshControl.test_executeRefresh() - + expect(refreshControl.allTargets.count) == 0 } - + it("unbinds actions for UIBarButtonItem") { var called = false let item = UIBarButtonItem() @@ -130,13 +130,12 @@ class BindToTests: QuickSpec { return .empty() }) item.rx.bind(to: action, input: "Hi there!") - + item.rx.unbindAction() _ = item.target?.perform(item.action!, with: item) - + expect(called).to( beFalse() ) } } } } - diff --git a/Tests/iOS-Tests/ButtonTests.swift b/Tests/iOS-Tests/ButtonTests.swift index feeddcee..4ae7f5b0 100644 --- a/Tests/iOS-Tests/ButtonTests.swift +++ b/Tests/iOS-Tests/ButtonTests.swift @@ -104,9 +104,9 @@ class ButtonTests: QuickSpec { expect(disposed) == true } - + it("cancels the observable if the button is deallocated") { - + var disposed = false waitUntil { done in @@ -125,7 +125,7 @@ class ButtonTests: QuickSpec { subject.rx.action?.execute() } } - + expect(disposed) == true } } diff --git a/Tests/iOS-Tests/RefreshControlTests.swift b/Tests/iOS-Tests/RefreshControlTests.swift index 18390056..9d95d820 100644 --- a/Tests/iOS-Tests/RefreshControlTests.swift +++ b/Tests/iOS-Tests/RefreshControlTests.swift @@ -47,7 +47,7 @@ class RefreshControlTests: QuickSpec { subject.rx.action = emptyAction(.just(false)) expect(subject.allTargets.count) == 1 - + expect(subject.isEnabled) == false } @@ -77,9 +77,9 @@ class RefreshControlTests: QuickSpec { // Setting the action has an asynchronous effect of adding a target. expect(subject.allTargets.count) == 1 - + subject.test_executeRefresh() - + expect(executed).toEventually( beTrue() ) } @@ -105,17 +105,17 @@ class RefreshControlTests: QuickSpec { expect(disposed) == true } - + it("disposes of old action subscriptions when re-set") { var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil) - + var disposed = false autoreleasepool { let disposeBag = DisposeBag() - + let action = emptyAction() subject.rx.action = action - + action .elements .subscribe(onNext: nil, onError: nil, onCompleted: nil, onDisposed: { @@ -123,11 +123,10 @@ class RefreshControlTests: QuickSpec { }) .disposed(by: disposeBag) } - + subject.rx.action = nil - + expect(disposed) == true } } } - diff --git a/Tests/macOS-Tests/BindToTests.swift b/Tests/macOS-Tests/BindToTests.swift index 37ecc910..b12135f7 100644 --- a/Tests/macOS-Tests/BindToTests.swift +++ b/Tests/macOS-Tests/BindToTests.swift @@ -26,12 +26,12 @@ class BindToTests: QuickSpec { button.rx.bind(to: action, input: "Hi there!") // Setting the action has an asynchronous effect of adding a target. expect(button.target).toEventuallyNot( beNil() ) - + button.test_executeAction() - + expect(called).toEventually( beTrue() ) } - + it("activates a generic control event") { var called = false let button = NSButton() @@ -42,13 +42,12 @@ class BindToTests: QuickSpec { button.rx.bind(to: action, controlEvent: button.rx.tap, inputTransform: { input in "\(input)" }) // Setting the action has an asynchronous effect of adding a target. expect(button.target).toEventuallyNot( beNil() ) - + button.test_executeAction() - + expect(called).toEventually( beTrue() ) } - - + describe("unbinding") { it("unbinds actions for UIButton") { let button = NSButton() @@ -59,13 +58,12 @@ class BindToTests: QuickSpec { button.rx.bind(to: action, input: "Hi there!") // Setting the action has an asynchronous effect of adding a target. expect(button.target).toEventuallyNot( beNil() ) - + button.rx.unbindAction() button.test_executeAction() - + expect(button.target).toEventually( beNil() ) } } } } - diff --git a/Tests/macOS-Tests/NSButtonTests.swift b/Tests/macOS-Tests/NSButtonTests.swift index 1c626430..b6abbe8f 100644 --- a/Tests/macOS-Tests/NSButtonTests.swift +++ b/Tests/macOS-Tests/NSButtonTests.swift @@ -7,25 +7,25 @@ import Action class NSButtonTests: QuickSpec { override func spec() { - + it("is nil by default") { let subject = NSButton() expect(subject.rx.action).to( beNil() ) } - + it("respects setter") { var subject = NSButton() - + let action = emptyAction() - + subject.rx.action = action - + expect(subject.rx.action) === action } - + it("disables the button while executing") { var subject = NSButton() - + var observer: AnyObserver! let action = CocoaAction(workFactory: { _ in return Observable.create { (obsv) -> Disposable in @@ -33,66 +33,66 @@ class NSButtonTests: QuickSpec { return Disposables.create() } }) - + subject.rx.action = action - + action.execute(()) expect(subject.isEnabled).toEventually( beFalse() ) - + observer.onCompleted() expect(subject.isEnabled).toEventually( beTrue() ) } - + it("disables the button if the Action is disabled") { var subject = NSButton() subject.rx.action = emptyAction(.just(false)) expect(subject.target).toEventuallyNot( beNil() ) - + expect(subject.isEnabled) == false } - + it("doesn't execute a disabled action when tapped") { var subject = NSButton() - + var executed = false subject.rx.action = CocoaAction(enabledIf: .just(false), workFactory: { _ in executed = true return .empty() }) - + subject.sendAction(on: .leftMouseDown) - + expect(executed) == false } - + it("executes the action when tapped") { var subject = NSButton() - + var executed = false let action = CocoaAction(workFactory: { _ in executed = true return .empty() }) subject.rx.action = action - + // Setting the action has an asynchronous effect of adding a target. expect(subject.target).toEventuallyNot( beNil() ) - + subject.test_executeAction() - + expect(executed).toEventually( beTrue() ) } - + it("disposes of old action subscriptions when re-set") { var subject = NSButton() - + var disposed = false autoreleasepool { let disposeBag = DisposeBag() - + let action = emptyAction() subject.rx.action = action - + action .elements .subscribe(onNext: nil, onError: nil, onCompleted: nil, onDisposed: { @@ -100,16 +100,16 @@ class NSButtonTests: QuickSpec { }) .disposed(by: disposeBag) } - + subject.rx.action = nil - + expect(disposed) == true } - + it("cancels the observable if the button is deallocated") { - + var disposed = false - + waitUntil { done in autoreleasepool { var subject = NSButton() @@ -121,7 +121,7 @@ class NSButtonTests: QuickSpec { } } } - + subject.rx.action = action #if swift(>=3.2) subject.rx.action?.execute(()) @@ -130,7 +130,7 @@ class NSButtonTests: QuickSpec { #endif } } - + expect(disposed) == true } } @@ -141,4 +141,3 @@ func emptyAction(_ enabledIf: Observable = .just(true)) -> CocoaAction { return .empty() }) } - From 5a74e853300606d8f41de1a406b12888381d7b71 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 1 May 2019 14:21:19 -0300 Subject: [PATCH 08/12] Update all to 5.0 --- Action.podspec | 4 ++-- Cartfile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Action.podspec b/Action.podspec index 3cb08116..d52bff15 100644 --- a/Action.podspec +++ b/Action.podspec @@ -20,8 +20,8 @@ Pod::Spec.new do |s| s.source_files = "Sources/**/*.{swift}" s.frameworks = "Foundation" - s.dependency "RxSwift", "~> 5.0.0" - s.dependency "RxCocoa", "~> 5.0.0" + s.dependency "RxSwift", "~> 5.0" + s.dependency "RxCocoa", "~> 5.0" s.watchos.exclude_files = "Control+Action.swift", "Button+Action.swift", "UIBarButtonItem+Action.swift", "UIAlertAction+Action.swift" s.osx.exclude_files = "UIBarButtonItem+Action.swift", "UIAlertAction+Action.swift" diff --git a/Cartfile b/Cartfile index 43e186b7..6a8bfd62 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "ReactiveX/RxSwift" ~> 5.0.0 +github "ReactiveX/RxSwift" ~> 5.0 From 85984dd78deb9bd75b9eb7a779fbba49f802a6ee Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 1 May 2019 14:40:02 -0300 Subject: [PATCH 09/12] Recorded.events() --- Tests/ActionTests/ActionTests.swift | 224 +++++++++++++++------------- 1 file changed, 123 insertions(+), 101 deletions(-) diff --git a/Tests/ActionTests/ActionTests.swift b/Tests/ActionTests/ActionTests.swift index 2bba9007..f6558aa4 100644 --- a/Tests/ActionTests/ActionTests.swift +++ b/Tests/ActionTests/ActionTests.swift @@ -32,10 +32,11 @@ class ActionTests: QuickSpec { } it("receives generated inputs") { scheduler.start() - XCTAssertEqual(inputs.events, [ - Recorded.next(10, "a"), - Recorded.next(20, "b") + XCTAssertEqual(inputs.events, Recorded.events([ + .next(10, "a"), + .next(20, "b") ]) + ) } it("emits nothing on `elements`") { let elements = scheduler.createObserver(Never.self) @@ -181,17 +182,19 @@ class ActionTests: QuickSpec { describe("single element action") { sharedExamples("send elements to elements observable") { it("work factory receives inputs") { - XCTAssertEqual(inputs.events, [ - Recorded.next(10, "a"), - Recorded.next(20, "b") + XCTAssertEqual(inputs.events, Recorded.events([ + .next(10, "a"), + .next(20, "b") ]) + ) } it("elements observable receives generated elements") { - XCTAssertEqual(elements.events, [ - Recorded.next(10, "a"), - Recorded.next(20, "b") + XCTAssertEqual(elements.events, Recorded.events([ + .next(10, "a"), + .next(20, "b") ]) + ) } it("errors observable receives nothing") { @@ -199,23 +202,25 @@ class ActionTests: QuickSpec { } it("disabled until element returns") { - XCTAssertEqual(enabled.events, [ - Recorded.next(0, true), - Recorded.next(10, false), - Recorded.next(10, true), - Recorded.next(20, false), - Recorded.next(20, true) + XCTAssertEqual(enabled.events, Recorded.events([ + .next(0, true), + .next(10, false), + .next(10, true), + .next(20, false), + .next(20, true) ]) + ) } it("executing until element returns") { - XCTAssertEqual(executing.events, [ - Recorded.next(0, false), - Recorded.next(10, true), - Recorded.next(10, false), - Recorded.next(20, true), - Recorded.next(20, false) + XCTAssertEqual(executing.events, Recorded.events([ + .next(0, false), + .next(10, true), + .next(10, false), + .next(20, true), + .next(20, false) ]) + ) } it("executes twice") { @@ -253,21 +258,23 @@ class ActionTests: QuickSpec { describe("multiple element action") { sharedExamples("send array elements to elements observable") { it("work factory receives inputs") { - XCTAssertEqual(inputs.events, [ - Recorded.next(10, "a"), - Recorded.next(20, "b") - ]) + XCTAssertEqual(inputs.events, Recorded.events([ + .next(10, "a"), + .next(20, "b") + ]) + ) } it("elements observable receives generated elements") { - XCTAssertEqual(elements.events, [ - Recorded.next(10, "a"), - Recorded.next(10, "b"), - Recorded.next(10, "c"), - Recorded.next(20, "b"), - Recorded.next(20, "c"), - Recorded.next(20, "d") + XCTAssertEqual(elements.events, Recorded.events([ + .next(10, "a"), + .next(10, "b"), + .next(10, "c"), + .next(20, "b"), + .next(20, "c"), + .next(20, "d") ]) + ) } it("errors observable receives nothing") { @@ -275,23 +282,25 @@ class ActionTests: QuickSpec { } it("disabled until element returns") { - XCTAssertEqual(enabled.events, [ - Recorded.next(0, true), - Recorded.next(10, false), - Recorded.next(10, true), - Recorded.next(20, false), - Recorded.next(20, true) + XCTAssertEqual(enabled.events, Recorded.events([ + .next(0, true), + .next(10, false), + .next(10, true), + .next(20, false), + .next(20, true) ]) + ) } it("executing until element returns") { - XCTAssertEqual(executing.events, [ - Recorded.next(0, false), - Recorded.next(10, true), - Recorded.next(10, false), - Recorded.next(20, true), - Recorded.next(20, false) + XCTAssertEqual(executing.events, Recorded.events([ + .next(0, false), + .next(10, true), + .next(10, false), + .next(20, true), + .next(20, false) ]) + ) } it("executes twice") { @@ -337,10 +346,11 @@ class ActionTests: QuickSpec { describe("error action") { sharedExamples("send errors to errors observable") { it("work factory receives inputs") { - XCTAssertEqual(inputs.events, [ - Recorded.next(10, "a"), - Recorded.next(20, "b") - ]) + XCTAssertEqual(inputs.events, Recorded.events([ + .next(10, "a"), + .next(20, "b") + ]) + ) } it("elements observable receives nothing") { @@ -348,10 +358,11 @@ class ActionTests: QuickSpec { } it("errors observable receives generated errors") { - XCTAssertEqual(errors.events, [ - Recorded.next(10, .underlyingError(TestError)), - Recorded.next(20, .underlyingError(TestError)) + XCTAssertEqual(errors.events, Recorded.events([ + .next(10, .underlyingError(TestError)), + .next(20, .underlyingError(TestError)) ]) + ) } it("underlyingError observable receives 2 generated errors") { @@ -366,23 +377,25 @@ class ActionTests: QuickSpec { } it("disabled until error returns") { - XCTAssertEqual(enabled.events, [ - Recorded.next(0, true), - Recorded.next(10, false), - Recorded.next(10, true), - Recorded.next(20, false), - Recorded.next(20, true) + XCTAssertEqual(enabled.events, Recorded.events([ + .next(0, true), + .next(10, false), + .next(10, true), + .next(20, false), + .next(20, true) ]) + ) } it("executing until error returns") { - XCTAssertEqual(executing.events, [ - Recorded.next(0, false), - Recorded.next(10, true), - Recorded.next(10, false), - Recorded.next(20, true), - Recorded.next(20, false) + XCTAssertEqual(executing.events, Recorded.events([ + .next(0, false), + .next(10, true), + .next(10, false), + .next(20, true), + .next(20, false) ]) + ) } it("executes twice") { @@ -428,10 +441,11 @@ class ActionTests: QuickSpec { } it("errors observable receives generated errors") { - XCTAssertEqual(errors.events, [ - Recorded.next(10, .notEnabled), - Recorded.next(20, .notEnabled) + XCTAssertEqual(errors.events, Recorded.events([ + .next(10, .notEnabled), + .next(20, .notEnabled) ]) + ) } it("underlyingError observable receives zero generated errors") { @@ -439,15 +453,17 @@ class ActionTests: QuickSpec { } it("disabled") { - XCTAssertEqual(enabled.events, [ - Recorded.next(0, false) + XCTAssertEqual(enabled.events, Recorded.events([ + .next(0, false) ]) + ) } it("never be executing") { - XCTAssertEqual(executing.events, [ - Recorded.next(0, false) + XCTAssertEqual(executing.events, Recorded.events([ + .next(0, false) ]) + ) } it("never executes") { @@ -519,14 +535,15 @@ class ActionTests: QuickSpec { bindAndExecuteTwice(action: action) } - it("element receives single value for each execution") { - XCTAssertEqual(element.events, [ - Recorded.next(10, "a"), - Recorded.completed(10), - Recorded.next(20, "b"), - Recorded.completed(20) - ]) - } + it("element receives single value for each execution") { + XCTAssertEqual(element.events, Recorded.events([ + .next(10, "a"), + .completed(10), + .next(20, "b"), + .completed(20) + ]) + ) + } it("executes twice") { expect(executionObservables.events.count) == 2 @@ -539,18 +556,19 @@ class ActionTests: QuickSpec { bindAndExecuteTwice(action: action) } - it("element receives 3 values for each execution") { - XCTAssertEqual(element.events, [ - Recorded.next(10, "a"), - Recorded.next(10, "a"), - Recorded.next(10, "a"), - Recorded.completed(10), - Recorded.next(20, "b"), - Recorded.next(20, "b"), - Recorded.next(20, "b"), - Recorded.completed(20) - ]) - } + it("element receives 3 values for each execution") { + XCTAssertEqual(element.events, Recorded.events([ + .next(10, "a"), + .next(10, "a"), + .next(10, "a"), + .completed(10), + .next(20, "b"), + .next(20, "b"), + .next(20, "b"), + .completed(20) + ]) + ) + } it("executes twice") { expect(executionObservables.events.count) == 2 @@ -564,10 +582,11 @@ class ActionTests: QuickSpec { } it("element fails with underlyingError") { - XCTAssertEqual(element.events, [ - Recorded.error(10, ActionError.underlyingError(TestError)), - Recorded.error(20, ActionError.underlyingError(TestError)) + XCTAssertEqual(element.events, Recorded.events([ + .error(10, ActionError.underlyingError(TestError)), + .error(20, ActionError.underlyingError(TestError)) ]) + ) } it("executes twice") { @@ -582,10 +601,11 @@ class ActionTests: QuickSpec { } it("element fails with notEnabled") { - XCTAssertEqual(element.events, [ - Recorded.error(10, ActionError.notEnabled), - Recorded.error(20, ActionError.notEnabled) + XCTAssertEqual(element.events, Recorded.events([ + .error(10, ActionError.notEnabled), + .error(20, ActionError.notEnabled) ]) + ) } it("never executes") { @@ -630,16 +650,18 @@ class ActionTests: QuickSpec { } it("first element receives single value") { - XCTAssertEqual(element.events, [ - Recorded.next(30, "a"), - Recorded.completed(30) + XCTAssertEqual(element.events, Recorded.events([ + .next(30, "a"), + .completed(30) ]) + ) } it("second element fails with notEnabled error") { - XCTAssertEqual(secondElement.events, [ - Recorded.error(20, ActionError.notEnabled) + XCTAssertEqual(secondElement.events, Recorded.events([ + .error(20, ActionError.notEnabled) ]) + ) } it("executes once") { From 890acc6dc7ca661540d0dd24109353582d6f0354 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 1 May 2019 14:45:31 -0300 Subject: [PATCH 10/12] Xcode ctrl + i --- Tests/ActionTests/ActionTests.swift | 480 ++++++++++++++-------------- 1 file changed, 240 insertions(+), 240 deletions(-) diff --git a/Tests/ActionTests/ActionTests.swift b/Tests/ActionTests/ActionTests.swift index f6558aa4..e79e7ef7 100644 --- a/Tests/ActionTests/ActionTests.swift +++ b/Tests/ActionTests/ActionTests.swift @@ -6,15 +6,15 @@ import RxTest @testable import Action class ActionTests: QuickSpec { - override func spec() { - var scheduler: TestScheduler! - var disposeBag: DisposeBag! - - beforeEach { - scheduler = TestScheduler(initialClock: 0) - disposeBag = DisposeBag() - } - + override func spec() { + var scheduler: TestScheduler! + var disposeBag: DisposeBag! + + beforeEach { + scheduler = TestScheduler(initialClock: 0) + disposeBag = DisposeBag() + } + describe("completable action") { var inputs: TestableObserver! var action: CompletableAction! @@ -33,10 +33,10 @@ class ActionTests: QuickSpec { it("receives generated inputs") { scheduler.start() XCTAssertEqual(inputs.events, Recorded.events([ - .next(10, "a"), - .next(20, "b") + .next(10, "a"), + .next(20, "b") ]) - ) + ) } it("emits nothing on `elements`") { let elements = scheduler.createObserver(Never.self) @@ -126,7 +126,7 @@ class ActionTests: QuickSpec { var executing: TestableObserver! var executionObservables: TestableObserver>! var underlyingError: TestableObserver! - + beforeEach { inputs = scheduler.createObserver(String.self) elements = scheduler.createObserver(String.self) @@ -183,43 +183,43 @@ class ActionTests: QuickSpec { sharedExamples("send elements to elements observable") { it("work factory receives inputs") { XCTAssertEqual(inputs.events, Recorded.events([ - .next(10, "a"), - .next(20, "b") - ]) + .next(10, "a"), + .next(20, "b") + ]) ) - } - - it("elements observable receives generated elements") { - XCTAssertEqual(elements.events, Recorded.events([ - .next(10, "a"), - .next(20, "b") - ]) + } + + it("elements observable receives generated elements") { + XCTAssertEqual(elements.events, Recorded.events([ + .next(10, "a"), + .next(20, "b") + ]) ) - } - - it("errors observable receives nothing") { - XCTAssertEqual(errors.events, []) - } - - it("disabled until element returns") { - XCTAssertEqual(enabled.events, Recorded.events([ - .next(0, true), - .next(10, false), - .next(10, true), - .next(20, false), - .next(20, true) - ]) + } + + it("errors observable receives nothing") { + XCTAssertEqual(errors.events, []) + } + + it("disabled until element returns") { + XCTAssertEqual(enabled.events, Recorded.events([ + .next(0, true), + .next(10, false), + .next(10, true), + .next(20, false), + .next(20, true) + ]) ) - } - - it("executing until element returns") { - XCTAssertEqual(executing.events, Recorded.events([ - .next(0, false), - .next(10, true), - .next(10, false), - .next(20, true), - .next(20, false) - ]) + } + + it("executing until element returns") { + XCTAssertEqual(executing.events, Recorded.events([ + .next(0, false), + .next(10, true), + .next(10, false), + .next(20, true), + .next(20, false) + ]) ) } @@ -263,43 +263,43 @@ class ActionTests: QuickSpec { .next(20, "b") ]) ) - } - - it("elements observable receives generated elements") { - XCTAssertEqual(elements.events, Recorded.events([ - .next(10, "a"), - .next(10, "b"), - .next(10, "c"), - .next(20, "b"), - .next(20, "c"), - .next(20, "d") - ]) + } + + it("elements observable receives generated elements") { + XCTAssertEqual(elements.events, Recorded.events([ + .next(10, "a"), + .next(10, "b"), + .next(10, "c"), + .next(20, "b"), + .next(20, "c"), + .next(20, "d") + ]) ) - } - - it("errors observable receives nothing") { - XCTAssertEqual(errors.events, []) - } - - it("disabled until element returns") { - XCTAssertEqual(enabled.events, Recorded.events([ - .next(0, true), - .next(10, false), - .next(10, true), - .next(20, false), - .next(20, true) - ]) + } + + it("errors observable receives nothing") { + XCTAssertEqual(errors.events, []) + } + + it("disabled until element returns") { + XCTAssertEqual(enabled.events, Recorded.events([ + .next(0, true), + .next(10, false), + .next(10, true), + .next(20, false), + .next(20, true) + ]) ) - } - - it("executing until element returns") { - XCTAssertEqual(executing.events, Recorded.events([ - .next(0, false), - .next(10, true), - .next(10, false), - .next(20, true), - .next(20, false) - ]) + } + + it("executing until element returns") { + XCTAssertEqual(executing.events, Recorded.events([ + .next(0, false), + .next(10, true), + .next(10, false), + .next(20, true), + .next(20, false) + ]) ) } @@ -351,50 +351,50 @@ class ActionTests: QuickSpec { .next(20, "b") ]) ) - } - - it("elements observable receives nothing") { - XCTAssertEqual(elements.events, []) - } - - it("errors observable receives generated errors") { + } + + it("elements observable receives nothing") { + XCTAssertEqual(elements.events, []) + } + + it("errors observable receives generated errors") { XCTAssertEqual(errors.events, Recorded.events([ - .next(10, .underlyingError(TestError)), - .next(20, .underlyingError(TestError)) - ]) + .next(10, .underlyingError(TestError)), + .next(20, .underlyingError(TestError)) + ]) ) - } - + } + it("underlyingError observable receives 2 generated errors") { XCTAssertEqual(underlyingError.events.count, 2) } - + it("underlyingError observable receives generated errors") { let first = underlyingError.events[0].value.element as! String let second = underlyingError.events[1].value.element as! String XCTAssertEqual(first, TestError) XCTAssertEqual(second, TestError) } - - it("disabled until error returns") { - XCTAssertEqual(enabled.events, Recorded.events([ - .next(0, true), - .next(10, false), - .next(10, true), - .next(20, false), - .next(20, true) - ]) + + it("disabled until error returns") { + XCTAssertEqual(enabled.events, Recorded.events([ + .next(0, true), + .next(10, false), + .next(10, true), + .next(20, false), + .next(20, true) + ]) ) - } - - it("executing until error returns") { - XCTAssertEqual(executing.events, Recorded.events([ - .next(0, false), - .next(10, true), - .next(10, false), - .next(20, true), - .next(20, false) - ]) + } + + it("executing until error returns") { + XCTAssertEqual(executing.events, Recorded.events([ + .next(0, false), + .next(10, true), + .next(10, false), + .next(20, true), + .next(20, false) + ]) ) } @@ -446,23 +446,23 @@ class ActionTests: QuickSpec { .next(20, .notEnabled) ]) ) - } - + } + it("underlyingError observable receives zero generated errors") { XCTAssertEqual(underlyingError.events.count, 0) } - - it("disabled") { - XCTAssertEqual(enabled.events, Recorded.events([ - .next(0, false) - ]) + + it("disabled") { + XCTAssertEqual(enabled.events, Recorded.events([ + .next(0, false) + ]) ) - } - - it("never be executing") { - XCTAssertEqual(executing.events, Recorded.events([ - .next(0, false) - ]) + } + + it("never be executing") { + XCTAssertEqual(executing.events, Recorded.events([ + .next(0, false) + ]) ) } @@ -544,18 +544,18 @@ class ActionTests: QuickSpec { ]) ) } - - it("executes twice") { - expect(executionObservables.events.count) == 2 - } - } - - context("multiple element action") { - beforeEach { - action = Action { Observable.of($0, $0, $0) } - bindAndExecuteTwice(action: action) - } - + + it("executes twice") { + expect(executionObservables.events.count) == 2 + } + } + + context("multiple element action") { + beforeEach { + action = Action { Observable.of($0, $0, $0) } + bindAndExecuteTwice(action: action) + } + it("element receives 3 values for each execution") { XCTAssertEqual(element.events, Recorded.events([ .next(10, "a"), @@ -569,121 +569,121 @@ class ActionTests: QuickSpec { ]) ) } - - it("executes twice") { - expect(executionObservables.events.count) == 2 - } - } - - context("error action") { - beforeEach { - action = Action { _ in Observable.error(TestError) } - bindAndExecuteTwice(action: action) - } - - it("element fails with underlyingError") { - XCTAssertEqual(element.events, Recorded.events([ + + it("executes twice") { + expect(executionObservables.events.count) == 2 + } + } + + context("error action") { + beforeEach { + action = Action { _ in Observable.error(TestError) } + bindAndExecuteTwice(action: action) + } + + it("element fails with underlyingError") { + XCTAssertEqual(element.events, Recorded.events([ .error(10, ActionError.underlyingError(TestError)), .error(20, ActionError.underlyingError(TestError)) - ]) + ]) ) - } - - it("executes twice") { - expect(executionObservables.events.count) == 2 - } - } - - context("disabled") { - beforeEach { - action = Action(enabledIf: Observable.just(false)) { Observable.just($0) } - bindAndExecuteTwice(action: action) - } - - it("element fails with notEnabled") { - XCTAssertEqual(element.events, Recorded.events([ + } + + it("executes twice") { + expect(executionObservables.events.count) == 2 + } + } + + context("disabled") { + beforeEach { + action = Action(enabledIf: Observable.just(false)) { Observable.just($0) } + bindAndExecuteTwice(action: action) + } + + it("element fails with notEnabled") { + XCTAssertEqual(element.events, Recorded.events([ .error(10, ActionError.notEnabled), .error(20, ActionError.notEnabled) - ]) + ]) ) - } - - it("never executes") { - expect(executionObservables.events).to(beEmpty()) - } - } - - context("execute while executing") { - var secondElement: TestableObserver! - var trigger: PublishSubject! - - beforeEach { - secondElement = scheduler.createObserver(String.self) - trigger = PublishSubject() - action = Action { Observable.just($0).sample(trigger) } - - action.executionObservables - .bind(to: executionObservables) - .disposed(by: disposeBag) - - scheduler.scheduleAt(10) { - action.execute("a") - .bind(to: element) - .disposed(by: disposeBag) - } - - scheduler.scheduleAt(20) { - action.execute("b") - .bind(to: secondElement) - .disposed(by: disposeBag) - } - - scheduler.scheduleAt(30) { - #if swift(>=3.2) - trigger.onNext(()) - #else - trigger.onNext() - #endif - } - - scheduler.start() - } - - it("first element receives single value") { - XCTAssertEqual(element.events, Recorded.events([ + } + + it("never executes") { + expect(executionObservables.events).to(beEmpty()) + } + } + + context("execute while executing") { + var secondElement: TestableObserver! + var trigger: PublishSubject! + + beforeEach { + secondElement = scheduler.createObserver(String.self) + trigger = PublishSubject() + action = Action { Observable.just($0).sample(trigger) } + + action.executionObservables + .bind(to: executionObservables) + .disposed(by: disposeBag) + + scheduler.scheduleAt(10) { + action.execute("a") + .bind(to: element) + .disposed(by: disposeBag) + } + + scheduler.scheduleAt(20) { + action.execute("b") + .bind(to: secondElement) + .disposed(by: disposeBag) + } + + scheduler.scheduleAt(30) { + #if swift(>=3.2) + trigger.onNext(()) + #else + trigger.onNext() + #endif + } + + scheduler.start() + } + + it("first element receives single value") { + XCTAssertEqual(element.events, Recorded.events([ .next(30, "a"), .completed(30) - ]) + ]) ) - } - - it("second element fails with notEnabled error") { - XCTAssertEqual(secondElement.events, Recorded.events([ + } + + it("second element fails with notEnabled error") { + XCTAssertEqual(secondElement.events, Recorded.events([ .error(20, ActionError.notEnabled) - ]) + ]) ) - } - - it("executes once") { - expect(executionObservables.events.count) == 1 - } - } - } - } + } + + it("executes once") { + expect(executionObservables.events.count) == 1 + } + } + } + } } extension ActionError: Equatable { - // Not accurate but convenient for testing. - public static func ==(lhs: ActionError, rhs: ActionError) -> Bool { - switch (lhs, rhs) { - case (.notEnabled, .notEnabled): - return true - case (.underlyingError, .underlyingError): - return true - default: - return false - } - } + // Not accurate but convenient for testing. + public static func ==(lhs: ActionError, rhs: ActionError) -> Bool { + switch (lhs, rhs) { + case (.notEnabled, .notEnabled): + return true + case (.underlyingError, .underlyingError): + return true + default: + return false + } + } } extension String: Error { } From 3ace10a721e3959fc1187dbc0f21e88478f7a5bd Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 1 May 2019 15:34:02 -0300 Subject: [PATCH 11/12] Align with XCT... --- Tests/ActionTests/ActionTests.swift | 144 ++++++++++++++-------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/Tests/ActionTests/ActionTests.swift b/Tests/ActionTests/ActionTests.swift index e79e7ef7..55512ee5 100644 --- a/Tests/ActionTests/ActionTests.swift +++ b/Tests/ActionTests/ActionTests.swift @@ -33,9 +33,9 @@ class ActionTests: QuickSpec { it("receives generated inputs") { scheduler.start() XCTAssertEqual(inputs.events, Recorded.events([ - .next(10, "a"), - .next(20, "b") - ]) + .next(10, "a"), + .next(20, "b") + ]) ) } it("emits nothing on `elements`") { @@ -214,12 +214,12 @@ class ActionTests: QuickSpec { it("executing until element returns") { XCTAssertEqual(executing.events, Recorded.events([ - .next(0, false), - .next(10, true), - .next(10, false), - .next(20, true), - .next(20, false) - ]) + .next(0, false), + .next(10, true), + .next(10, false), + .next(20, true), + .next(20, false) + ]) ) } @@ -267,13 +267,13 @@ class ActionTests: QuickSpec { it("elements observable receives generated elements") { XCTAssertEqual(elements.events, Recorded.events([ - .next(10, "a"), - .next(10, "b"), - .next(10, "c"), - .next(20, "b"), - .next(20, "c"), - .next(20, "d") - ]) + .next(10, "a"), + .next(10, "b"), + .next(10, "c"), + .next(20, "b"), + .next(20, "c"), + .next(20, "d") + ]) ) } @@ -283,23 +283,23 @@ class ActionTests: QuickSpec { it("disabled until element returns") { XCTAssertEqual(enabled.events, Recorded.events([ - .next(0, true), - .next(10, false), - .next(10, true), - .next(20, false), - .next(20, true) - ]) + .next(0, true), + .next(10, false), + .next(10, true), + .next(20, false), + .next(20, true) + ]) ) } it("executing until element returns") { XCTAssertEqual(executing.events, Recorded.events([ - .next(0, false), - .next(10, true), - .next(10, false), - .next(20, true), - .next(20, false) - ]) + .next(0, false), + .next(10, true), + .next(10, false), + .next(20, true), + .next(20, false) + ]) ) } @@ -359,9 +359,9 @@ class ActionTests: QuickSpec { it("errors observable receives generated errors") { XCTAssertEqual(errors.events, Recorded.events([ - .next(10, .underlyingError(TestError)), - .next(20, .underlyingError(TestError)) - ]) + .next(10, .underlyingError(TestError)), + .next(20, .underlyingError(TestError)) + ]) ) } @@ -378,23 +378,23 @@ class ActionTests: QuickSpec { it("disabled until error returns") { XCTAssertEqual(enabled.events, Recorded.events([ - .next(0, true), - .next(10, false), - .next(10, true), - .next(20, false), - .next(20, true) - ]) + .next(0, true), + .next(10, false), + .next(10, true), + .next(20, false), + .next(20, true) + ]) ) } it("executing until error returns") { XCTAssertEqual(executing.events, Recorded.events([ - .next(0, false), - .next(10, true), - .next(10, false), - .next(20, true), - .next(20, false) - ]) + .next(0, false), + .next(10, true), + .next(10, false), + .next(20, true), + .next(20, false) + ]) ) } @@ -454,15 +454,15 @@ class ActionTests: QuickSpec { it("disabled") { XCTAssertEqual(enabled.events, Recorded.events([ - .next(0, false) - ]) + .next(0, false) + ]) ) } it("never be executing") { XCTAssertEqual(executing.events, Recorded.events([ - .next(0, false) - ]) + .next(0, false) + ]) ) } @@ -537,11 +537,11 @@ class ActionTests: QuickSpec { it("element receives single value for each execution") { XCTAssertEqual(element.events, Recorded.events([ - .next(10, "a"), - .completed(10), - .next(20, "b"), - .completed(20) - ]) + .next(10, "a"), + .completed(10), + .next(20, "b"), + .completed(20) + ]) ) } @@ -558,15 +558,15 @@ class ActionTests: QuickSpec { it("element receives 3 values for each execution") { XCTAssertEqual(element.events, Recorded.events([ - .next(10, "a"), - .next(10, "a"), - .next(10, "a"), - .completed(10), - .next(20, "b"), - .next(20, "b"), - .next(20, "b"), - .completed(20) - ]) + .next(10, "a"), + .next(10, "a"), + .next(10, "a"), + .completed(10), + .next(20, "b"), + .next(20, "b"), + .next(20, "b"), + .completed(20) + ]) ) } @@ -583,9 +583,9 @@ class ActionTests: QuickSpec { it("element fails with underlyingError") { XCTAssertEqual(element.events, Recorded.events([ - .error(10, ActionError.underlyingError(TestError)), - .error(20, ActionError.underlyingError(TestError)) - ]) + .error(10, ActionError.underlyingError(TestError)), + .error(20, ActionError.underlyingError(TestError)) + ]) ) } @@ -602,9 +602,9 @@ class ActionTests: QuickSpec { it("element fails with notEnabled") { XCTAssertEqual(element.events, Recorded.events([ - .error(10, ActionError.notEnabled), - .error(20, ActionError.notEnabled) - ]) + .error(10, ActionError.notEnabled), + .error(20, ActionError.notEnabled) + ]) ) } @@ -651,16 +651,16 @@ class ActionTests: QuickSpec { it("first element receives single value") { XCTAssertEqual(element.events, Recorded.events([ - .next(30, "a"), - .completed(30) - ]) + .next(30, "a"), + .completed(30) + ]) ) } it("second element fails with notEnabled error") { XCTAssertEqual(secondElement.events, Recorded.events([ - .error(20, ActionError.notEnabled) - ]) + .error(20, ActionError.notEnabled) + ]) ) } From 524688f3e43e3b6f15a0e6caea28aada2d965c97 Mon Sep 17 00:00:00 2001 From: Luciano Almeida Date: Wed, 1 May 2019 19:49:53 -0300 Subject: [PATCH 12/12] Adjustments on identation --- Tests/ActionTests/ActionTests.swift | 30 +++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Tests/ActionTests/ActionTests.swift b/Tests/ActionTests/ActionTests.swift index 55512ee5..fa46768d 100644 --- a/Tests/ActionTests/ActionTests.swift +++ b/Tests/ActionTests/ActionTests.swift @@ -75,7 +75,10 @@ class ActionTests: QuickSpec { it("execute on .next") { scheduler.scheduleAt(10) { action.inputs.onNext("a") } scheduler.start() - XCTAssertEqual(inputs.events, [next(10, "a")]) + XCTAssertEqual(inputs.events, Recorded.events([ + .next(10, "a") + ]) + ) XCTAssertEqual(executions.events.filter { !$0.value.isStopEvent }.count, 1) } it("ignore .error events") { @@ -94,10 +97,11 @@ class ActionTests: QuickSpec { scheduler.scheduleAt(10) { action.inputs.onNext("a") } scheduler.scheduleAt(20) { action.inputs.onNext("b") } scheduler.start() - XCTAssertEqual(inputs.events, [ - next(10, "a"), - next(20, "b"), - ]) + XCTAssertEqual(inputs.events, Recorded.events([ + .next(10, "a"), + .next(20, "b"), + ]) + ) XCTAssertEqual(executions.events.filter { !$0.value.isStopEvent }.count, 2) XCTAssertEqual(executions.events.filter { $0.value.isStopEvent }.count, 0) } @@ -105,7 +109,10 @@ class ActionTests: QuickSpec { scheduler.scheduleAt(10) { action.inputs.onError(TestError) } scheduler.scheduleAt(20) { action.inputs.onNext("b") } scheduler.start() - XCTAssertEqual(inputs.events, [next(20, "b")]) + XCTAssertEqual(inputs.events, Recorded.events([ + .next(20, "b") + ]) + ) XCTAssertEqual(executions.events.filter { !$0.value.isStopEvent }.count, 1) XCTAssertEqual(executions.events.filter { $0.value.isStopEvent }.count, 0) } @@ -113,7 +120,10 @@ class ActionTests: QuickSpec { scheduler.scheduleAt(10) { action.inputs.onCompleted() } scheduler.scheduleAt(20) { action.inputs.onNext("b") } scheduler.start() - XCTAssertEqual(inputs.events, [next(20, "b")]) + XCTAssertEqual(inputs.events, Recorded.events([ + .next(20, "b") + ]) + ) XCTAssertEqual(executions.events.filter { !$0.value.isStopEvent }.count, 1) XCTAssertEqual(executions.events.filter { $0.value.isStopEvent }.count, 0) } @@ -442,9 +452,9 @@ class ActionTests: QuickSpec { it("errors observable receives generated errors") { XCTAssertEqual(errors.events, Recorded.events([ - .next(10, .notEnabled), - .next(20, .notEnabled) - ]) + .next(10, .notEnabled), + .next(20, .notEnabled) + ]) ) }