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://www.api.com/api/v2/places?api_key=MY_API_KEY"]);
});
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?
The way to go would be to mock the URL and API key that APIRoutes holds and test that you get the expected complete mock URL. This way you only test the logic and not the specific value of the URL.