Reputation: 1466
I'm writing some Kiwi specs to test the authentication system in my app, specifically loading a set of stored credentials. The example works by stubbing methods in NSUserDefaults
and SSKeychain
to return fixed data, which the authentication class then uses to configure my API client. The code looks something like this:
it(@"authenticates the client with saved credentials", ^{
[NSUserDefaults stub:@selector(standardUserDefaults) andReturn:@{MoneyBrilliantActiveAccountKey: @"[email protected]"}];
[SSKeychain stub:@selector(passwordForService:account:) andReturn:@"fooBarBaz"];
[[mockRequestSerializer should] receive:@selector(setValue:forHTTPHeaderField:) withCount:2];
MyAuthManager *newAuthManager = [[MyAuthManager alloc] initWithAPIClient:mockAPIClient];
[[theValue([newAuthManager isAuthenticated]) should] beNo];
[[theValue([newAuthManager authenticateClientWithSavedCredentials]) should] beYes];
[[theValue([newAuthManager isAuthenticated]) should] beYes];
});
However, this example fails, and I've managed to track the reason why down to my stubbed implementation of +passwordForService:account:
not being called on SSKeychain
.
Is there something obvious I'm missing that would prevent this stub from being called?
Upvotes: 1
Views: 319