Intro
I'd like to test that the right frame is set on a views subview (which is injected as a mock).
However I can't seem to find a way to verify that the right CGRect is set
Current Attempt
-(void)testThatCorrectFrameIsSet {
//Arrange
MKTArgumentCaptor *argumentCaptor = [[MKTargumentCaptor alloc] init];
self.sut.subView = mock([UIView class]);
//Act
[self.sut awakeFromNib];
//Assert
[[[MKTVerify(self.sut.subView) withMatcher:[argumentCaptor capture]] setFrame:CGSizeZero];
expect([argumentCaptor.value CGRectValue].size.x).to.beCloseToWithin(42, 0.001);
}
What's going wrong
I get:
"NSInvalidArgumentException", "-[_NSInlineData CGRectValue]: unrecognized selector sent to instance 0x7af325c0"
Which makes me wonder how to correctly capture CGRect values
Side Note
I am aware of the fact that I could inject an actual UIView instead of a mocked one, however the actual code I'm testing prevents me from doing this for reasons that would make this question harder than needed.
I think you should use 'CGRectZero' instead of 'CGSizeZero', but this doesn't solve the Problem.
It looks like the captor value is not an NSValue.
Hope this helps to track down the problem.