mardi 2 juin 2015

Unit testing secret keys

I am using cocoapods-keys and trying to test if the method returns valid url with secret API key.

Test suite looks like this:

it(@"should return valid url for api", ^{
    NSURL *url = [APIRoutes apiURLWithPath:path parameters:nil];
    expect([url absoluteString]).to.equal([NSString stringWithFormat:@"http://ift.tt/1FqqADA"]);
});

But the real method is returning my valid API key which is hash (e.g. 8s97f89asf89asf987saf) and my test fails. How can I test this? Should I create fake implementation of my class in my test file?

Aucun commentaire:

Enregistrer un commentaire