Last active
December 11, 2015 09:28
-
-
Save frosty/4580197 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation ADNClient | |
+ (id)sharedClient | |
{ | |
static dispatch_once_t pred = 0; | |
__strong static id _sharedObject = nil; | |
dispatch_once(&pred, ^{ | |
_sharedObject = [[self alloc] init]; | |
}); | |
return _sharedObject; | |
} | |
- (id)init | |
{ | |
self = [super initWithBaseURL:[NSURL URLWithString:@"https://alpha-api.app.net/stream/0/posts/stream/global"]]; | |
if (self) | |
{ | |
[self setUpToReceiveJSON]; | |
} | |
return self; | |
} | |
- (void)setUpToReceiveJSON | |
{ | |
[self registerHTTPOperationClass:[AFJSONRequestOperation class]]; | |
[self setDefaultHeader:@"Accept" value:@"application/json"]; | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Kiwi/Kiwi.h> | |
#import "AFNetworking.h" | |
#import "ADNClient.h" | |
@interface ADNClient () | |
- (void)setUpToReceiveJSON; | |
@end | |
SPEC_BEGIN(ADNClientSpec) | |
describe(@"An ADNClient", ^{ | |
__block ADNClient *client; | |
beforeEach(^{ | |
client = [ADNClient sharedClient]; | |
}); | |
afterEach(^{ | |
client = nil; | |
}); | |
context(@"when created", ^{ | |
it(@"should not be nil", ^{ | |
[client shouldNotBeNil]; | |
}); | |
it(@"should be a singleton", ^{ | |
ADNClient *newClient = [ADNClient sharedClient]; | |
[[newClient should] beIdenticalTo:client]; | |
}); | |
it(@"should be set up to handle JSON", ^{ | |
// err... ? | |
}); | |
}); | |
}); | |
SPEC_END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment