{"action":"created","issue":{"url":"https://api.github.com/repos/erikdoe/ocmock/issues/172","labels_url":"https://api.github.com/repos/erikdoe/ocmock/issues/172/labels{/name}","comments_url":"https://api.github.com/repos/erikdoe/ocmock/issues/172/comments","events_url":"https://api.github.com/repos/erikdoe/ocmock/issues/172/events","html_url":"https://github.com/erikdoe/ocmock/issues/172","id":54787807,"number":172,"title":"When using +[OCMArg checkWithBlock:], block gets invoked twice.","user":{"login":"michaelmelanson","id":1318,"avatar_url":"https://avatars.githubusercontent.com/u/1318?v=3","gravatar_id":"","url":"https://api.github.com/users/michaelmelanson","html_url":"https://github.com/michaelmelanson","followers_url":"https://api.github.com/users/michaelmelanson/followers","following_url":"https://api.github.com/users/michaelmelanson/following{/other_user}","gists_url":"https://api.github.com/users/michaelmelanson/gists{/gist_id}","starred_url":"https://api.github.com/users/michaelmelanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/michaelmelanson/subscriptions","organizations_url":"https://api.github.com/users/michaelmelanson/orgs","repos_url":"https://api.github.com/users/michaelmelanson/repos","events_url":"https://api.github.com/users/michaelmelanson/events{/privacy}","received_events_url":"https://api.github.com/users/michaelmelanson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-01-19T16:59:32Z","updated_at":"2015-02-17T12:31:57Z","closed_at":null,"body":"This is a regression in OCMock v3.1.2.\r\n\r\nIn commit f3a8ff2, merged in OCMock v3.1.2, the invocation handling logic changed. It now first checks all the stubs with `matchesInvocation:`, then at the end it calls `handleInvocation:`. In both cases, the arguments to the stub are evaluated. This means that when one of the arguments is the result of `+[OCMArg checkWithBlock:]`, this means that its block gets invoked twice -- in OCMock v3.1.1 it would be invoked once.\r\n\r\nTo give an example, in our test suite we have test cases that look like this:\r\n\r\n    [[mockOne expect] someMethod];\r\n    [mockTwo stub] doMethodWithBlock:[OCMArg checkWithBlock:^BOOL(void(^block)()) {\r\n        if (block) block();\r\n        return YES;\r\n    }]];\r\n\r\n    [objectUnderTest run];\r\n\r\nWhere the purpose of the test is to verify that `-[objectUnderTest run]` calls `-[mockTwo doMethodWithBlock:]`, passing a block which calls `-[mockOne someMethod]`. Assuming `mockOne` is strict (not nice) this will pass in OCMock v3.1.1, but fail in v3.1.2 because mockOne only expects one invocation of `someMethod`."},"comment":{"url":"https://api.github.com/repos/erikdoe/ocmock/issues/comments/74660774","html_url":"https://github.com/erikdoe/ocmock/issues/172#issuecomment-74660774","issue_url":"https://api.github.com/repos/erikdoe/ocmock/issues/172","id":74660774,"user":{"login":"erikdoe","id":954026,"avatar_url":"https://avatars.githubusercontent.com/u/954026?v=3","gravatar_id":"","url":"https://api.github.com/users/erikdoe","html_url":"https://github.com/erikdoe","followers_url":"https://api.github.com/users/erikdoe/followers","following_url":"https://api.github.com/users/erikdoe/following{/other_user}","gists_url":"https://api.github.com/users/erikdoe/gists{/gist_id}","starred_url":"https://api.github.com/users/erikdoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erikdoe/subscriptions","organizations_url":"https://api.github.com/users/erikdoe/orgs","repos_url":"https://api.github.com/users/erikdoe/repos","events_url":"https://api.github.com/users/erikdoe/events{/privacy}","received_events_url":"https://api.github.com/users/erikdoe/received_events","type":"User","site_admin":false},"created_at":"2015-02-17T12:31:57Z","updated_at":"2015-02-17T12:31:57Z","body":"Well it was a bit more than a week, but it should be fixed now, back to the old \"invoke the block once\" behaviour."}}