Skip to content

Commit

Permalink
Functional specs to values for app id, key and secret from ENV vars, if
Browse files Browse the repository at this point in the history
they are supplied. Basically setup for Travis support
  • Loading branch information
hamchapman committed Jun 29, 2016
1 parent 3da04b6 commit cab9441
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Functional Specs/SpecHelper.m
Expand Up @@ -27,7 +27,13 @@
}

PTPusher *newTestClientDisconnected(void) {
PTPusher *client = [PTPusher pusherWithKey:PUSHER_API_KEY delegate:[PTPusherClientTestHelperDelegate sharedInstance] encrypted:NO];
NSDictionary *environment = [[NSProcessInfo processInfo] environment];
NSString *appKey = environment[@"PUSHER_APP_KEY"];

if (!appKey)
appKey = PUSHER_API_KEY;

PTPusher *client = [PTPusher pusherWithKey:appKey delegate:[PTPusherClientTestHelperDelegate sharedInstance] encrypted:NO];
return client;
}

Expand All @@ -43,10 +49,22 @@ void sendTestEvent(NSString *eventName)

void sendTestEventOnChannel(NSString *channelName, NSString *eventName)
{
NSDictionary *environment = [[NSProcessInfo processInfo] environment];
NSString *appId = environment[@"PUSHER_APP_ID"];
NSString *appKey = environment[@"PUSHER_APP_KEY"];
NSString *appSecret = environment[@"PUSHER_APP_SECRET"];

if (!appId)
appId = PUSHER_APP_ID;
if (!appKey)
appKey = PUSHER_API_KEY;
if (!appSecret)
appSecret = PUSHER_API_SECRET;

__strong static PTPusherAPI *_sharedAPI = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedAPI = [[PTPusherAPI alloc] initWithKey:PUSHER_API_KEY appID:PUSHER_APP_ID secretKey:PUSHER_API_SECRET];
_sharedAPI = [[PTPusherAPI alloc] initWithKey:appKey appID:appId secretKey:appSecret];
});

[_sharedAPI triggerEvent:eventName onChannel:channelName data:[NSArray arrayWithObject:@"dummy data"] socketID:@"99999.99999"];
Expand Down

0 comments on commit cab9441

Please sign in to comment.