forked from yfactorial/objectiveresource
/
DogErrorTest.m
49 lines (34 loc) · 1.04 KB
/
DogErrorTest.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
//
// DogErrorTest.m
// active_resource
//
// Created by James Burka on 12/29/08.
// Copyright 2008 Burkaprojects. All rights reserved.
//
#import "DogErrorTest.h"
@implementation DogError
+ (NSString *)getORSSite {
return @"http://localhost:36313/";
}
@end
@implementation DogDoesNotExist
+ (NSString *)getORSSite {
return @"http://badhost.localhost:9999/";
}
@end
@implementation DogErrorTest
- (void) test404Error {
NSError *aError;
[DogError findAllWithResponse:&aError];
STAssertEquals([aError code], 404, @"Should have returned 404 error instead got %d " ,
[aError code]);
}
- (void) testCantFindServer {
NSError *aError;
[DogDoesNotExist findAllWithResponse:&aError];
STAssertTrue([[aError domain] isEqualToString:NSURLErrorDomain],
@"Should have returned NSURLErrorDomain error instead got %@ " , [aError domain]);
STAssertEquals([aError code], NSURLErrorCannotFindHost, @"Should have returned NSURLErrorCannotFindHost(-1003) error instead got %d " ,
[aError code]);
}
@end