Closed nakp closed 7 years ago
I have 2 mock's in a array, and properly stubbed both's name property (mock1.name = @"mock1" and mock2.name = @"mock2", items is the array holding both objects)
mock1.name = @"mock1"
mock2.name = @"mock2"
items
[mock1 stub:@selector(name) andReturn:@"mock1"]; ... NSPredicate *filter= [NSPredicate predicateWithFormat:@"name = %@", @"mock1"]; NSArray *filteredArray = [items filteredArrayUsingPredicate:filter];
returns an empty array, can't we use stubs with predicates?
The solution is to also stub the method valueForKey that NSPredicate uses, like this:
[mock1 stub:@selector(valueForKey:) andReturn:@"mock1" withArguments:@"name"]
I have 2 mock's in a array, and properly stubbed both's name property (
mock1.name = @"mock1"
andmock2.name = @"mock2"
,items
is the array holding both objects)returns an empty array, can't we use stubs with predicates?