Skip to content

Instantly share code, notes, and snippets.

@thiagolioy
Created August 28, 2015 20:02
Show Gist options
  • Save thiagolioy/01add707aff57a348590 to your computer and use it in GitHub Desktop.
Save thiagolioy/01add707aff57a348590 to your computer and use it in GitHub Desktop.
+(NSDictionary*)parse:(NSDictionary*)dc{
NSMutableDictionary *mutDc = [NSMutableDictionary dictionaryWithDictionary:dc];
for(NSString *key in mutDc.allKeys){
NSString *value = [mutDc objectForKey:key];
if([value isEqualToString:@"true"])
[mutDc setObject:@YES forKey:key];
else if([value isEqualToString:@"false"])
[mutDc setObject:@NO forKey:key];
}
return (NSDictionary*)mutDc;
}
it(@"should parse bool strings", ^{
NSDictionary *dc = @{
@"first":@"true",
@"second":@"false",
@"third":@"anotherThing"
};
NSDictionary *expec = [IPFValidator parse:dc];
expect(expec[@"first"]).to.beTruthy();
expect(expec[@"second"]).to.beFalsy();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment