-
Notifications
You must be signed in to change notification settings - Fork 496
/
Copy pathNSURLConnectionRACSupportSpec.m
39 lines (30 loc) · 1.1 KB
/
NSURLConnectionRACSupportSpec.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
//
// NSURLConnectionRACSupportSpec.m
// ReactiveObjC
//
// Created by Justin Spahr-Summers on 2013-10-01.
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
//
@import Quick;
@import Nimble;
#import "NSURLConnection+RACSupport.h"
#import "RACSignal+Operations.h"
#import "RACTuple.h"
QuickSpecBegin(NSURLConnectionRACSupportSpec)
qck_it(@"should fetch a JSON file", ^{
NSURL *fileURL = [[NSBundle bundleForClass:self.class] URLForResource:@"test-data" withExtension:@"json"];
expect(fileURL).notTo(beNil());
NSURLRequest *request = [NSURLRequest requestWithURL:fileURL];
BOOL success = NO;
NSError *error = nil;
RACTuple *result = [[NSURLConnection rac_sendAsynchronousRequest:request] firstOrDefault:nil success:&success error:&error];
expect(@(success)).to(beTruthy());
expect(error).to(beNil());
expect(result).to(beAKindOf(RACTuple.class));
NSURLResponse *response = result.first;
expect(response).to(beAKindOf(NSURLResponse.class));
NSData *data = result.second;
expect(data).to(beAKindOf(NSData.class));
expect(data).to(equal([NSData dataWithContentsOfURL:fileURL]));
});
QuickSpecEnd