{"action":"created","issue":{"url":"https://api.github.com/repos/rspec/rspec-mocks/issues/915","labels_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/915/labels{/name}","comments_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/915/comments","events_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/915/events","html_url":"https://github.com/rspec/rspec-mocks/issues/915","id":64437672,"number":915,"title":"Confusing failure message for `have_received(...).with(...).once`","user":{"login":"myronmarston","id":49391,"avatar_url":"https://avatars.githubusercontent.com/u/49391?v=3","gravatar_id":"","url":"https://api.github.com/users/myronmarston","html_url":"https://github.com/myronmarston","followers_url":"https://api.github.com/users/myronmarston/followers","following_url":"https://api.github.com/users/myronmarston/following{/other_user}","gists_url":"https://api.github.com/users/myronmarston/gists{/gist_id}","starred_url":"https://api.github.com/users/myronmarston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myronmarston/subscriptions","organizations_url":"https://api.github.com/users/myronmarston/orgs","repos_url":"https://api.github.com/users/myronmarston/repos","events_url":"https://api.github.com/users/myronmarston/events{/privacy}","received_events_url":"https://api.github.com/users/myronmarston/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rspec/rspec-mocks/labels/small","name":"small","color":"0052cc"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-26T04:19:24Z","updated_at":"2015-04-09T18:15:39Z","closed_at":"2015-04-09T18:15:39Z","body":"Consider this spec:\r\n\r\n``` ruby\r\nRSpec.describe \"Using `have_rececive(:message).with(:args).once`\" do\r\n  it \"mentions the count discrepancy in the failure message\" do\r\n    dbl = double.as_null_object\r\n    dbl.foo(:one)\r\n    dbl.foo(:two)\r\n    dbl.foo(:one)\r\n\r\n    expect(dbl).to have_received(:foo).with(:one).once\r\n  end\r\nend\r\n```\r\n\r\nIt fails, which is correct, but the failure message is really confusing:\r\n\r\n```\r\n  1) Using `have_rececive(:message).with(:args).once` mentions the count discrepancy in the failure message\r\n     Failure/Error: expect(dbl).to have_received(:foo).with(:one).once\r\n       Double received :foo with unexpected arguments\r\n         expected: (:one)\r\n              got: (:two)\r\n       Diff:\r\n       @@ -1,2 +1,2 @@\r\n       -[:one]\r\n       +[:two]\r\n```\r\n\r\nThe fact that it received `foo` with `:two` is immaterial.  It's that it received the message with `:one` twice, not once, that causes the failure -- but the failure message doesn't say that.\r\n\r\nNote: this started as #841 (which has some failing specs I sketched out) but I've not had a chance to get back to that and probably won't any time soon.  I wanted to convert it to an issue to make it clear it's a free issue for anyone to work on :).  Feel free to borrow as much of the spec changes in #841 as you like, though.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/rspec/rspec-mocks/issues/comments/91316514","html_url":"https://github.com/rspec/rspec-mocks/issues/915#issuecomment-91316514","issue_url":"https://api.github.com/repos/rspec/rspec-mocks/issues/915","id":91316514,"user":{"login":"myronmarston","id":49391,"avatar_url":"https://avatars.githubusercontent.com/u/49391?v=3","gravatar_id":"","url":"https://api.github.com/users/myronmarston","html_url":"https://github.com/myronmarston","followers_url":"https://api.github.com/users/myronmarston/followers","following_url":"https://api.github.com/users/myronmarston/following{/other_user}","gists_url":"https://api.github.com/users/myronmarston/gists{/gist_id}","starred_url":"https://api.github.com/users/myronmarston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myronmarston/subscriptions","organizations_url":"https://api.github.com/users/myronmarston/orgs","repos_url":"https://api.github.com/users/myronmarston/repos","events_url":"https://api.github.com/users/myronmarston/events{/privacy}","received_events_url":"https://api.github.com/users/myronmarston/received_events","type":"User","site_admin":false},"created_at":"2015-04-09T18:15:39Z","updated_at":"2015-04-09T18:15:39Z","body":"Fixed by #918."}}