RKTestNotificationObserver Class Reference
Inherits from | NSObject |
Declared in | RKTestNotificationObserver.h |
Overview
An RKTestNotificationObserver object provides support for awaiting a notification to be posted as the result of an asynchronous operation by spinning the run loop. This enables a straight-forward unit testing workflow by blocking execution of the test until a notification is posted.
Tasks
-
name
The name of the notification the receiver is awaiting.
property -
object
The object expected to post the notification the receiver is awaiting.
property -
timeout
The timeout interval, in seconds, to wait for the notification to be posted.
property -
+ notificationObserver
Creates and initializes a notification obsercer object.
-
+ notificationObserverForName:object:
Instantiate a notification observer for the given notification name and object
-
+ notificationObserverForName:
Instantiate a notification observer for the given notification name
-
– addObserver
Adds the receiver as an observer for the notification name and object under test.
-
– waitForNotification
Wait for a notification matching the name and source object we are observing to be posted.
-
+ waitForNotificationWithName:object:usingBlock:
Configures a notification observer to wait for the a notification with the given name to be posted by the source object during execution of the block.
-
+ waitForNotificationWithName:usingBlock:
Configures a notification observer to wait for the a notification with the given name to be posted during execution of the block.
Properties
name
The name of the notification the receiver is awaiting.
@property (nonatomic, copy) NSString *name
Declared In
RKTestNotificationObserver.h
Class Methods
notificationObserver
Creates and initializes a notification obsercer object.
+ (RKTestNotificationObserver *)notificationObserver
Return Value
The newly created notification observer.
Declared In
RKTestNotificationObserver.h
notificationObserverForName:
Instantiate a notification observer for the given notification name
+ (RKTestNotificationObserver *)notificationObserverForName:(NSString *)notificationName
Parameters
- notificationName
The name of the NSNotification we want to watch for
Declared In
RKTestNotificationObserver.h
notificationObserverForName:object:
+ (RKTestNotificationObserver *)notificationObserverForName:(NSString *)notificationName object:(id)notificationSender
Parameters
- notificationName
The name of the NSNotification we want to watch for
- notificationSender
The source object of the NSNotification we want to watch for
Return Value
The newly created notification observer initialized with notificationName and notificationSender.
Declared In
RKTestNotificationObserver.h
waitForNotificationWithName:object:usingBlock:
Configures a notification observer to wait for the a notification with the given name to be posted by the source object during execution of the block.
+ (void)waitForNotificationWithName:(NSString *)name object:(id)notificationSender usingBlock:(void ( ^ ) ( ))block
Parameters
- name
The name of the notification we are waiting for
- notificationSender
The object we are waiting to post the notification
- block
A block to invoke to trigger the notification activity
Declared In
RKTestNotificationObserver.h
waitForNotificationWithName:usingBlock:
Configures a notification observer to wait for the a notification with the given name to be posted during execution of the block.
+ (void)waitForNotificationWithName:(NSString *)name usingBlock:(void ( ^ ) ( ))block
Parameters
- name
The name of the notification we are waiting for
- block
A block to invoke to trigger the notification activity
Declared In
RKTestNotificationObserver.h
Instance Methods
addObserver
- (void)addObserver
Discussion
If the observer has not already been added when waitForNotification is invoked, it will be added before the runloop cycling begins.
Declared In
RKTestNotificationObserver.h