4

So I have a method that has the following signature, in a class called PopoverProvider

- (void)showPopoverForAction:(MESAction *)action fromRect:(CGRect)rect inView:(UIView *)view onDoneBlock:(MESActionPopoverDoneBlock)block;

And I want to verify that it gets called like so:

// popoverProvider is a PopoverProvider
                            [[[popoverProvider expect] andReturn:mockRecipeIngredientViewController]
                                    showPopoverForAction:[OCMArg any]
                                                fromRect:[OCMArg any] // !!!!
                                                  inView:[OCMArg any]
                                             onDoneBlock:[OCMArg any]
                            ];

The marked line causes a problem: [OCMArg any] doesn't match on CGRects, which is a struct type.

fatuhoku
  • 4,815
  • 3
  • 30
  • 70

1 Answers1

4

In this case, since you don't care about the value of the rect, I'd use:

[[[[popoverProvider expect] andReturn:mockRecipeIngredientViewController] ignoringNonObjectArgs]
                 showPopoverForAction:[OCMArg any]
                             fromRect:CGRectMake(0.0f,0.0f,0.0f,0.0f)
                               inView:[OCMArg any]
                          onDoneBlock:[OCMArg any]
];

If you had a case where you wanted to ignore one struct but check another you could do this:

[[[[[popoverProvider expect] andReturn:mockRecipeIngredientViewController] ignoringNonObjectArgs]  andDo:^(NSInvocation *invocation) {
        CGRect theSize;
        [invocation getArgument:&theSize atIndex:6];
        STAssertEquals(theSize, CGSizeMake(20.0f,20.0f), @"No match!");
    }]
                 showPopoverForAction:[OCMArg any]
                             fromRect:CGRectMake(0.0f,0.0f,0.0f,0.0f)
                               inView:[OCMArg any]
                          onDoneBlock:[OCMArg any]
                             someSize:CGSizeMake(0.0f,0.0f)
];
Ben Flynn
  • 18,524
  • 20
  • 97
  • 142