Skip to content

Instantly share code, notes, and snippets.

@frosty
Last active December 11, 2015 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frosty/4580197 to your computer and use it in GitHub Desktop.
Save frosty/4580197 to your computer and use it in GitHub Desktop.
@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
#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