forked from ReactiveCocoa/ReactiveCocoa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ReactiveCocoa#2039 from ReactiveCocoa/nsnotif-prod…
…ucer NSNotificationCenter.rac_notifications returns a producer
- Loading branch information
Showing
3 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// FoundationExtensionsSpec.swift | ||
// ReactiveCocoa | ||
// | ||
// Created by Neil Pankey on 5/22/15. | ||
// Copyright (c) 2015 GitHub. All rights reserved. | ||
// | ||
|
||
import Result | ||
import Nimble | ||
import Quick | ||
import ReactiveCocoa | ||
|
||
class FoundationExtensionsSpec: QuickSpec { | ||
override func spec() { | ||
describe("NSNotificationCenter.rac_notifications") { | ||
|
||
it("should send notifications on the producer") { | ||
let center = NSNotificationCenter.defaultCenter() | ||
let producer = center.rac_notifications(name: "rac_notifications_test") | ||
|
||
var notif: NSNotification? = nil | ||
let disposable = producer.start(next: { notif = $0 }) | ||
|
||
center.postNotificationName("some_other_notification", object: nil) | ||
expect(notif).to(beNil()) | ||
|
||
center.postNotificationName("rac_notifications_test", object: nil) | ||
expect(notif?.name).to(equal("rac_notifications_test")) | ||
|
||
notif = nil | ||
disposable.dispose() | ||
|
||
center.postNotificationName("rac_notifications_test", object: nil) | ||
expect(notif).to(beNil()) | ||
} | ||
} | ||
} | ||
} |