Skip to content

Commit

Permalink
Merge pull request #54 from RxSwiftCommunity/2.0-final
Browse files Browse the repository at this point in the history
Final 2.0 Release
  • Loading branch information
ashfurrow authored Oct 24, 2016
2 parents b0fb8c9 + 4ab4188 commit 8c335d8
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 44 deletions.
6 changes: 3 additions & 3 deletions Action.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Action"
s.version = "2.0.0-beta.1"
s.version = "2.0.0"
s.summary = "Abstracts actions to be performed in RxSwift."
s.description = <<-DESC
Encapsulates an action to be performed, usually by a UIButton press.
Expand All @@ -21,8 +21,8 @@ Pod::Spec.new do |s|
s.source_files = "*.{swift}"

s.frameworks = "Foundation"
s.dependency "RxSwift"
s.dependency "RxCocoa"
s.dependency "RxSwift", "~> 3.0"
s.dependency "RxCocoa", "~> 3.0"

s.watchos.exclude_files = "UIButton+Rx.swift", "UIBarButtonItem+Action.swift", "AlertAction.swift"
s.osx.exclude_files = "UIButton+Rx.swift", "UIBarButtonItem+Action.swift", "AlertAction.swift"
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "ReactiveX/RxSwift" "3.0.0-rc.1"
github "ReactiveX/RxSwift" ~> 3.0.0
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "Quick/Nimble" "v5.0.0"
github "Quick/Nimble" "v5.1.0"
github "Quick/Quick" "v0.10.0"
github "ReactiveX/RxSwift" "3.0.0-rc.1"
github "ReactiveX/RxSwift" "3.0.0"
2 changes: 1 addition & 1 deletion Carthage/Checkouts/Nimble
Submodule Nimble updated 58 files
+3 −1 .gitignore
+3 −3 .travis.yml
+8 −0 CONTRIBUTING.md
+1 −1 Gemfile
+28 −26 Gemfile.lock
+30 −4 Nimble.podspec
+124 −10 Nimble.xcodeproj/project.pbxproj
+2 −2 Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-tvOS.xcscheme
+2 −1 Package.swift
+79 −7 README.md
+3 −0 Sources/Lib/CwlPreconditionTesting/CwlCatchException/.gitignore
+30 −0 Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.h
+35 −0 Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.m
+32 −0 Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.swift
+28 −0 Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/Info.plist
+76 −0 Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift
+61 −0 Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.h
+50 −0 Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.m
+194 −0 Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift
+100 −0 Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift
+63 −0 Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift
+28 −0 Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/Info.plist
+537 −0 Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/mach_excServer.c
+298 −0 Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/mach_excServer.h
+80 −0 Sources/Lib/CwlPreconditionTesting/README.md
+2 −2 Sources/Nimble/Adapters/NimbleEnvironment.swift
+7 −2 Sources/Nimble/DSL+Wait.swift
+2 −4 Sources/Nimble/Matchers/AsyncMatcherWrapper.swift
+1 −1 Sources/Nimble/Matchers/BeLessThan.swift
+4 −4 Sources/Nimble/Matchers/BeLogical.swift
+2 −2 Sources/Nimble/Matchers/Match.swift
+55 −0 Sources/Nimble/Matchers/ThrowAssertion.swift
+7 −0 Sources/Nimble/Nimble.h
+20 −9 Sources/Nimble/Utils/Async.swift
+12 −5 Sources/Nimble/Utils/Errors.swift
+263 −31 Sources/NimbleObjectiveC/DSL.h
+14 −8 Sources/NimbleObjectiveC/DSL.m
+2 −2 Tests/LinuxMain.swift
+3 −7 Tests/NimbleTests/AsynchronousTest.swift
+1 −2 Tests/NimbleTests/Helpers/utils.swift
+5 −0 Tests/NimbleTests/Matchers/MatchErrorTest.swift
+0 −3 Tests/NimbleTests/Matchers/MatchTest.swift
+62 −0 Tests/NimbleTests/Matchers/ThrowAssertionTest.swift
+0 −1 Tests/NimbleTests/Matchers/ThrowErrorTest.swift
+3 −3 Tests/NimbleTests/SynchronousTests.swift
+0 −6 Tests/NimbleTests/UserDescriptionTest.swift
+11 −0 Tests/NimbleTests/objc/ObjCBeCloseToTest.m
+22 −0 Tests/NimbleTests/objc/ObjCBeFalseTest.m
+32 −2 Tests/NimbleTests/objc/ObjCBeFalsyTest.m
+9 −0 Tests/NimbleTests/objc/ObjCBeGreaterThanOrEqualToTest.m
+8 −0 Tests/NimbleTests/objc/ObjCBeGreaterThanTest.m
+6 −0 Tests/NimbleTests/objc/ObjCBeIdenticalToTest.m
+10 −0 Tests/NimbleTests/objc/ObjCBeLessThanOrEqualToTest.m
+9 −0 Tests/NimbleTests/objc/ObjCBeLessThanTest.m
+22 −0 Tests/NimbleTests/objc/ObjCBeTrueTest.m
+27 −0 Tests/NimbleTests/objc/ObjCBeTruthyTest.m
+59 −0 Tests/NimbleTests/objc/ObjCEqualTest.m
+70 −1 Tests/NimbleTests/objc/ObjCHaveCount.m
2 changes: 1 addition & 1 deletion Carthage/Checkouts/RxSwift
Submodule RxSwift updated 321 files
76 changes: 54 additions & 22 deletions Tests/Action/ActionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,15 @@ class ActionTests: QuickSpec {
let subject = errorSubject()
var errored = false

subject
.execute()
.subscribe(onError: { _ in
errored = true
})
.addDisposableTo(disposeBag)
waitUntil { done in
subject
.execute()
.subscribe(onError: { _ in
errored = true
done()
})
.addDisposableTo(disposeBag)
}

expect(errored) == true
}
Expand Down Expand Up @@ -148,9 +151,17 @@ class ActionTests: QuickSpec {
})
.addDisposableTo(disposeBag)

subject.execute()
waitUntil { done in
subject
.execute()
.subscribe(onCompleted: {
done()
})
.addDisposableTo(disposeBag)
}

expect(elements) == [true, false]

expect(elements).toEventually( equal([true, false]) )
}

sharedExamples("sending elements") { (context: @escaping SharedExampleContext) -> Void in
Expand Down Expand Up @@ -196,9 +207,11 @@ class ActionTests: QuickSpec {
let subject = testSubject(testItems)
var receivedElements: [String] = []

subject.execute().subscribe(onNext: { (element) -> Void in
receivedElements += [element]
}).addDisposableTo(disposeBag)
waitUntil { done in
subject.execute().subscribe(onNext: { (element) -> Void in
receivedElements += [element]
}, onCompleted: done).addDisposableTo(disposeBag)
}

expect(receivedElements) == testItems
}
Expand Down Expand Up @@ -232,12 +245,15 @@ class ActionTests: QuickSpec {
let subject = emptySubject()
var completed = false

subject
.execute()
.subscribe(onCompleted: {
completed = true
})
.addDisposableTo(disposeBag)
waitUntil { done in
subject
.execute()
.subscribe(onCompleted: {
completed = true
done()
})
.addDisposableTo(disposeBag)
}

expect(completed) == true
}
Expand All @@ -249,7 +265,13 @@ class ActionTests: QuickSpec {
return .empty()
})

subject.execute()
waitUntil { done in
subject.execute()
.subscribe(onCompleted: {
done()
})
.addDisposableTo(disposeBag)
}

expect(invocations) == 1
}
Expand Down Expand Up @@ -281,13 +303,23 @@ class ActionTests: QuickSpec {

executer.execute(subject)

var enabled = try! subject.enabled.toBlocking().first()
expect(enabled) == false
expect(try! subject.enabled.toBlocking().first()).toEventually( beFalse() )
}

it("is externally re-enabled after executing") {
var observer: AnyObserver<Void>!
let subject = Action<Void, Void>(workFactory: { _ in
return Observable.create { (obsv) -> Disposable in
observer = obsv
return Disposables.create()
}
})

executer.execute(subject)

observer.onCompleted()

enabled = try! subject.enabled.toBlocking().first()
expect(enabled) == true
expect(try! subject.enabled.toBlocking().first()).toEventually( beTrue() )
}
}

Expand Down
5 changes: 4 additions & 1 deletion Tests/Action/BarButtonTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class BarButtonTests: QuickSpec {
var subject = UIBarButtonItem(barButtonSystemItem: .save, target: nil, action: nil)

subject.rx.action = emptyAction(.just(false))
expect(subject.target).toEventuallyNot( beNil() )

expect(subject.isEnabled) == false
}
Expand Down Expand Up @@ -73,7 +74,9 @@ class BarButtonTests: QuickSpec {
return .empty()
})
subject.rx.action = action

// Setting the action has the asynchronous effect of adding a target.
expect(subject.target).toEventuallyNot( beNil() )

_ = subject.target?.perform(subject.action, with: subject)

expect(executed) == true
Expand Down
29 changes: 18 additions & 11 deletions Tests/Action/ButtonTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ButtonTests: QuickSpec {
var subject = UIButton(type: .system)

subject.rx.action = emptyAction(.just(false))
expect(subject.allTargets).toEventuallyNot( beEmpty() )

expect(subject.isEnabled) == false
}
Expand Down Expand Up @@ -74,14 +75,17 @@ class ButtonTests: QuickSpec {
})
subject.rx.action = action

// Setting the action has an asynchronous effect of adding a target.
expect(subject.allTargets).toEventuallyNot( beEmpty() )

// Normally I'd use subject.sendActionsForControlEvents(.TouchUpInside) but it's not working
for case let target as NSObject in subject.allTargets {
for action in subject.actions(forTarget: target, forControlEvent: .touchUpInside) ?? [] {
target.perform(Selector(action), with: subject)
}
}

expect(executed) == true
expect(executed).toEventually( beTrue() )
}

it("disposes of old action subscriptions when re-set") {
Expand Down Expand Up @@ -110,19 +114,22 @@ class ButtonTests: QuickSpec {
it("cancels the observable if the button is deallocated") {

var disposed = false

autoreleasepool {
var subject = UIButton(type: .system)
let action = CocoaAction {
return Observable.create {_ in
Disposables.create {
disposed = true

waitUntil { done in
autoreleasepool {
var subject = UIButton(type: .system)
let action = CocoaAction {
return Observable.create {_ in
Disposables.create {
disposed = true
done()
}
}
}

subject.rx.action = action
subject.rx.action?.execute()
}

subject.rx.action = action
subject.rx.action?.execute()
}

expect(disposed) == true
Expand Down
2 changes: 1 addition & 1 deletion UIBarButtonItem+Action.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public extension Reactive where Base: UIBarButtonItem {
if let action = newValue {
action
.enabled
.bindTo(self.enabled)
.bindTo(self.isEnabled)
.addDisposableTo(self.base.actionDisposeBag)

self.tap.subscribe(onNext: { (_) in
Expand Down
2 changes: 1 addition & 1 deletion UIButton+Rx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public extension Reactive where Base: UIButton {
if let action = newValue {
action
.enabled
.bindTo(self.enabled)
.bindTo(self.isEnabled)
.addDisposableTo(self.base.actionDisposeBag)

// Technically, this file is only included on tv/iOS platforms,
Expand Down

0 comments on commit 8c335d8

Please sign in to comment.