Merge pull request #1019 from kylef/init

[AFHTTPClient init] should raise an exception
This commit is contained in:
Mattt Thompson 2013-05-22 08:32:44 -07:00
commit c9eb2d380c
2 changed files with 10 additions and 0 deletions

View File

@ -221,6 +221,12 @@ NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) {
return [[self alloc] initWithBaseURL:url];
}
- (instancetype)init {
@throw [NSException exceptionWithName:NSInternalInconsistencyException
reason:[NSString stringWithFormat:@"%@ Failed to call designated initializer. Invoke `initWithBaseURL:` instead.", NSStringFromClass([self class])]
userInfo:nil];
}
- (id)initWithBaseURL:(NSURL *)url {
NSParameterAssert(url);

View File

@ -35,6 +35,10 @@
#pragma mark -
- (void)testInitRaisesException {
expect(^{ (void)[[AFHTTPClient alloc] init]; }).to.raiseAny();
}
- (void)testDefaultHeaders {
[self.client setDefaultHeader:@"x-some-key" value:@"SomeValue"];
expect([self.client defaultValueForHeader:@"x-some-key"]).to.equal(@"SomeValue");