xarly
xarly

Reputation: 2144

Return primitive values in OCMock

I tried the documentation: http://ocmock.org/reference/#argument-constraints and I can't make work to return any value different of 0

My code is working with:

    OCMStub([self.mockCurrentUser tipOptionSelected]).andReturn(0);

How can I do something like:

    OCMStub([self.mockCurrentUser tipOptionSelected]).andReturn(OCMOCK_VALUE([OCMArg isNotEqual:0]);

I want to that my stub return any Int except 0.

Thanks

Upvotes: 0

Views: 303

Answers (1)

Erik Doernenburg
Erik Doernenburg

Reputation: 3014

It feels like you misunderstood something. A stub (by definition) has to return a predefined value. The return value is programmed behaviour of the stub. The matching occurs on the arguments to determine whether the stub matches the invocation. This is also why they are called argument constraints.

Upvotes: 1

Related Questions