forked from ReactiveCocoa/ReactiveObjC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRACChannelSpec.m
76 lines (60 loc) · 2.01 KB
/
RACChannelSpec.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// RACChannelSpec.m
// ReactiveObjC
//
// Created by Uri Baghin on 30/12/2012.
// Copyright (c) 2012 GitHub, Inc. All rights reserved.
//
@import Quick;
@import Nimble;
#import "RACChannelExamples.h"
#import "NSObject+RACDeallocating.h"
#import "RACChannel.h"
#import "RACCompoundDisposable.h"
#import "RACDisposable.h"
#import "RACSignal.h"
QuickSpecBegin(RACChannelSpec)
qck_describe(@"RACChannel", ^{
qck_itBehavesLike(RACChannelExamples, ^{
return @{
RACChannelExampleCreateBlock: [^{
return [[RACChannel alloc] init];
} copy]
};
});
qck_describe(@"memory management", ^{
qck_it(@"should dealloc when its subscribers are disposed", ^{
RACDisposable *leadingDisposable = nil;
RACDisposable *followingDisposable = nil;
__block BOOL deallocated = NO;
@autoreleasepool {
RACChannel *channel __attribute__((objc_precise_lifetime)) = [[RACChannel alloc] init];
[channel.rac_deallocDisposable addDisposable:[RACDisposable disposableWithBlock:^{
deallocated = YES;
}]];
leadingDisposable = [channel.leadingTerminal subscribeCompleted:^{}];
followingDisposable = [channel.followingTerminal subscribeCompleted:^{}];
}
[leadingDisposable dispose];
[followingDisposable dispose];
expect(@(deallocated)).toEventually(beTruthy());
});
qck_it(@"should dealloc when its subscriptions are disposed", ^{
RACDisposable *leadingDisposable = nil;
RACDisposable *followingDisposable = nil;
__block BOOL deallocated = NO;
@autoreleasepool {
RACChannel *channel __attribute__((objc_precise_lifetime)) = [[RACChannel alloc] init];
[channel.rac_deallocDisposable addDisposable:[RACDisposable disposableWithBlock:^{
deallocated = YES;
}]];
leadingDisposable = [[RACSignal never] subscribe:channel.leadingTerminal];
followingDisposable = [[RACSignal never] subscribe:channel.followingTerminal];
}
[leadingDisposable dispose];
[followingDisposable dispose];
expect(@(deallocated)).toEventually(beTruthy());
});
});
});
QuickSpecEnd