I didn't see anything in the README or Wiki on how to do this. So I wrote a quick post on
.
__block MovieCompletion completion;
beforeEach(^{
completion = nil;
service stub_method(@selector(getMoviesWithCompletion:))
.and_do_block(^(MovieCompletion localCompletion) {
completion = localCompletion;
});
subject.view should_not be_nil;
});
context(@"when the service returns movies", ^{
beforeEach(^{
Movie *movie1 = [[Movie alloc] initWithName:@"Movie One"];
Movie *movie2 = [[Movie alloc] initWithName:@"Movie Two"];
completion(@[ movie1, movie2 ], nil);
});
it(@"should populate the table", ^{
[subject.tableView.visibleCells valueForKeyPath:@"textLabel.text"]
should equal(@[ @"Movie One", @"Movie Two" ]);
});
});