{"action":"created","comment":{"url":"https://api.github.com/repos/mjackson/expect/pulls/comments/46074295","id":46074295,"diff_hunk":"@@ -333,10 +333,21 @@ class Expectation {\n     const expectedArgs = Array.prototype.slice.call(arguments, 0)\n \n     assert(\n+        spy.calls.length > 0,\n+        ('spy was not called')\n+    )\n+\n+\n+    let actualArguments = ''\n+    for(const arg of spy.calls) {\n+      actualArguments =  actualArguments + '- ' + JSON.stringify(arg.arguments) + '\\n'\n+    }\n+    const message = 'spy was never called with:\\n%s.\\n\\nIt was called with:\\n' + actualArguments","path":"modules/Expectation.js","position":13,"original_position":13,"commit_id":"c406a4a5dea88e5f5639f1107669d0a9d5e4e5d1","original_commit_id":"c406a4a5dea88e5f5639f1107669d0a9d5e4e5d1","user":{"login":"khronnuz","id":315656,"avatar_url":"https://avatars.githubusercontent.com/u/315656?v=3","gravatar_id":"","url":"https://api.github.com/users/khronnuz","html_url":"https://github.com/khronnuz","followers_url":"https://api.github.com/users/khronnuz/followers","following_url":"https://api.github.com/users/khronnuz/following{/other_user}","gists_url":"https://api.github.com/users/khronnuz/gists{/gist_id}","starred_url":"https://api.github.com/users/khronnuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khronnuz/subscriptions","organizations_url":"https://api.github.com/users/khronnuz/orgs","repos_url":"https://api.github.com/users/khronnuz/repos","events_url":"https://api.github.com/users/khronnuz/events{/privacy}","received_events_url":"https://api.github.com/users/khronnuz/received_events","type":"User","site_admin":false},"body":"I tried using the `%s` place holder instead of the concatenation here, but it did not interpreted the `\\n`, outputting it literally without breaking the line.  ","created_at":"2015-11-28T01:06:22Z","updated_at":"2015-11-28T01:06:22Z","html_url":"https://github.com/mjackson/expect/pull/48#discussion_r46074295","pull_request_url":"https://api.github.com/repos/mjackson/expect/pulls/48","_links":{"self":{"href":"https://api.github.com/repos/mjackson/expect/pulls/comments/46074295"},"html":{"href":"https://github.com/mjackson/expect/pull/48#discussion_r46074295"},"pull_request":{"href":"https://api.github.com/repos/mjackson/expect/pulls/48"}}},"pull_request":{"url":"https://api.github.com/repos/mjackson/expect/pulls/48","id":52030342,"html_url":"https://github.com/mjackson/expect/pull/48","diff_url":"https://github.com/mjackson/expect/pull/48.diff","patch_url":"https://github.com/mjackson/expect/pull/48.patch","issue_url":"https://api.github.com/repos/mjackson/expect/issues/48","number":48,"state":"open","locked":false,"title":"Improves error message for toHaveBeenCalledWith","user":{"login":"khronnuz","id":315656,"avatar_url":"https://avatars.githubusercontent.com/u/315656?v=3","gravatar_id":"","url":"https://api.github.com/users/khronnuz","html_url":"https://github.com/khronnuz","followers_url":"https://api.github.com/users/khronnuz/followers","following_url":"https://api.github.com/users/khronnuz/following{/other_user}","gists_url":"https://api.github.com/users/khronnuz/gists{/gist_id}","starred_url":"https://api.github.com/users/khronnuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khronnuz/subscriptions","organizations_url":"https://api.github.com/users/khronnuz/orgs","repos_url":"https://api.github.com/users/khronnuz/repos","events_url":"https://api.github.com/users/khronnuz/events{/privacy}","received_events_url":"https://api.github.com/users/khronnuz/received_events","type":"User","site_admin":false},"body":"Often when trying test using spied on functions, I find it hard to debug because you cannot tell if the function was called at all or which arguments it was called with. In this PR I try to address both issues by:\r\n\r\n- short circuit and let the user know that the function was not called, instead of the `spy was never called with xxx`.\r\n- in case it was called but not with the expected arguments, list the arguments it was called.\r\n\r\nAgain, thanks for the library and I am happy to address any issues you have with my proposed changes.\r\n","created_at":"2015-11-28T01:04:32Z","updated_at":"2015-11-28T01:06:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0fe7dfc944faa42e2ac3ff1e1b5bb8a467f7e865","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mjackson/expect/pulls/48/commits","review_comments_url":"https://api.github.com/repos/mjackson/expect/pulls/48/comments","review_comment_url":"https://api.github.com/repos/mjackson/expect/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mjackson/expect/issues/48/comments","statuses_url":"https://api.github.com/repos/mjackson/expect/statuses/c406a4a5dea88e5f5639f1107669d0a9d5e4e5d1","head":{"label":"khronnuz:toHaveBeenCalledWith","ref":"toHaveBeenCalledWith","sha":"c406a4a5dea88e5f5639f1107669d0a9d5e4e5d1","user":{"login":"khronnuz","id":315656,"avatar_url":"https://avatars.githubusercontent.com/u/315656?v=3","gravatar_id":"","url":"https://api.github.com/users/khronnuz","html_url":"https://github.com/khronnuz","followers_url":"https://api.github.com/users/khronnuz/followers","following_url":"https://api.github.com/users/khronnuz/following{/other_user}","gists_url":"https://api.github.com/users/khronnuz/gists{/gist_id}","starred_url":"https://api.github.com/users/khronnuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khronnuz/subscriptions","organizations_url":"https://api.github.com/users/khronnuz/orgs","repos_url":"https://api.github.com/users/khronnuz/repos","events_url":"https://api.github.com/users/khronnuz/events{/privacy}","received_events_url":"https://api.github.com/users/khronnuz/received_events","type":"User","site_admin":false},"repo":{"id":41862621,"name":"expect","full_name":"khronnuz/expect","owner":{"login":"khronnuz","id":315656,"avatar_url":"https://avatars.githubusercontent.com/u/315656?v=3","gravatar_id":"","url":"https://api.github.com/users/khronnuz","html_url":"https://github.com/khronnuz","followers_url":"https://api.github.com/users/khronnuz/followers","following_url":"https://api.github.com/users/khronnuz/following{/other_user}","gists_url":"https://api.github.com/users/khronnuz/gists{/gist_id}","starred_url":"https://api.github.com/users/khronnuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khronnuz/subscriptions","organizations_url":"https://api.github.com/users/khronnuz/orgs","repos_url":"https://api.github.com/users/khronnuz/repos","events_url":"https://api.github.com/users/khronnuz/events{/privacy}","received_events_url":"https://api.github.com/users/khronnuz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/khronnuz/expect","description":"Write better assertions","fork":true,"url":"https://api.github.com/repos/khronnuz/expect","forks_url":"https://api.github.com/repos/khronnuz/expect/forks","keys_url":"https://api.github.com/repos/khronnuz/expect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/khronnuz/expect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/khronnuz/expect/teams","hooks_url":"https://api.github.com/repos/khronnuz/expect/hooks","issue_events_url":"https://api.github.com/repos/khronnuz/expect/issues/events{/number}","events_url":"https://api.github.com/repos/khronnuz/expect/events","assignees_url":"https://api.github.com/repos/khronnuz/expect/assignees{/user}","branches_url":"https://api.github.com/repos/khronnuz/expect/branches{/branch}","tags_url":"https://api.github.com/repos/khronnuz/expect/tags","blobs_url":"https://api.github.com/repos/khronnuz/expect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/khronnuz/expect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/khronnuz/expect/git/refs{/sha}","trees_url":"https://api.github.com/repos/khronnuz/expect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/khronnuz/expect/statuses/{sha}","languages_url":"https://api.github.com/repos/khronnuz/expect/languages","stargazers_url":"https://api.github.com/repos/khronnuz/expect/stargazers","contributors_url":"https://api.github.com/repos/khronnuz/expect/contributors","subscribers_url":"https://api.github.com/repos/khronnuz/expect/subscribers","subscription_url":"https://api.github.com/repos/khronnuz/expect/subscription","commits_url":"https://api.github.com/repos/khronnuz/expect/commits{/sha}","git_commits_url":"https://api.github.com/repos/khronnuz/expect/git/commits{/sha}","comments_url":"https://api.github.com/repos/khronnuz/expect/comments{/number}","issue_comment_url":"https://api.github.com/repos/khronnuz/expect/issues/comments{/number}","contents_url":"https://api.github.com/repos/khronnuz/expect/contents/{+path}","compare_url":"https://api.github.com/repos/khronnuz/expect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/khronnuz/expect/merges","archive_url":"https://api.github.com/repos/khronnuz/expect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/khronnuz/expect/downloads","issues_url":"https://api.github.com/repos/khronnuz/expect/issues{/number}","pulls_url":"https://api.github.com/repos/khronnuz/expect/pulls{/number}","milestones_url":"https://api.github.com/repos/khronnuz/expect/milestones{/number}","notifications_url":"https://api.github.com/repos/khronnuz/expect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/khronnuz/expect/labels{/name}","releases_url":"https://api.github.com/repos/khronnuz/expect/releases{/id}","created_at":"2015-09-03T13:56:30Z","updated_at":"2015-09-03T13:56:30Z","pushed_at":"2015-11-28T00:58:04Z","git_url":"git://github.com/khronnuz/expect.git","ssh_url":"git@github.com:khronnuz/expect.git","clone_url":"https://github.com/khronnuz/expect.git","svn_url":"https://github.com/khronnuz/expect","homepage":"","size":165,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mjackson:master","ref":"master","sha":"1608bba25a664f653b326a5295491c8eb46c1b4a","user":{"login":"mjackson","id":92839,"avatar_url":"https://avatars.githubusercontent.com/u/92839?v=3","gravatar_id":"","url":"https://api.github.com/users/mjackson","html_url":"https://github.com/mjackson","followers_url":"https://api.github.com/users/mjackson/followers","following_url":"https://api.github.com/users/mjackson/following{/other_user}","gists_url":"https://api.github.com/users/mjackson/gists{/gist_id}","starred_url":"https://api.github.com/users/mjackson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjackson/subscriptions","organizations_url":"https://api.github.com/users/mjackson/orgs","repos_url":"https://api.github.com/users/mjackson/repos","events_url":"https://api.github.com/users/mjackson/events{/privacy}","received_events_url":"https://api.github.com/users/mjackson/received_events","type":"User","site_admin":false},"repo":{"id":17575045,"name":"expect","full_name":"mjackson/expect","owner":{"login":"mjackson","id":92839,"avatar_url":"https://avatars.githubusercontent.com/u/92839?v=3","gravatar_id":"","url":"https://api.github.com/users/mjackson","html_url":"https://github.com/mjackson","followers_url":"https://api.github.com/users/mjackson/followers","following_url":"https://api.github.com/users/mjackson/following{/other_user}","gists_url":"https://api.github.com/users/mjackson/gists{/gist_id}","starred_url":"https://api.github.com/users/mjackson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjackson/subscriptions","organizations_url":"https://api.github.com/users/mjackson/orgs","repos_url":"https://api.github.com/users/mjackson/repos","events_url":"https://api.github.com/users/mjackson/events{/privacy}","received_events_url":"https://api.github.com/users/mjackson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mjackson/expect","description":"Write better assertions","fork":false,"url":"https://api.github.com/repos/mjackson/expect","forks_url":"https://api.github.com/repos/mjackson/expect/forks","keys_url":"https://api.github.com/repos/mjackson/expect/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mjackson/expect/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mjackson/expect/teams","hooks_url":"https://api.github.com/repos/mjackson/expect/hooks","issue_events_url":"https://api.github.com/repos/mjackson/expect/issues/events{/number}","events_url":"https://api.github.com/repos/mjackson/expect/events","assignees_url":"https://api.github.com/repos/mjackson/expect/assignees{/user}","branches_url":"https://api.github.com/repos/mjackson/expect/branches{/branch}","tags_url":"https://api.github.com/repos/mjackson/expect/tags","blobs_url":"https://api.github.com/repos/mjackson/expect/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mjackson/expect/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mjackson/expect/git/refs{/sha}","trees_url":"https://api.github.com/repos/mjackson/expect/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mjackson/expect/statuses/{sha}","languages_url":"https://api.github.com/repos/mjackson/expect/languages","stargazers_url":"https://api.github.com/repos/mjackson/expect/stargazers","contributors_url":"https://api.github.com/repos/mjackson/expect/contributors","subscribers_url":"https://api.github.com/repos/mjackson/expect/subscribers","subscription_url":"https://api.github.com/repos/mjackson/expect/subscription","commits_url":"https://api.github.com/repos/mjackson/expect/commits{/sha}","git_commits_url":"https://api.github.com/repos/mjackson/expect/git/commits{/sha}","comments_url":"https://api.github.com/repos/mjackson/expect/comments{/number}","issue_comment_url":"https://api.github.com/repos/mjackson/expect/issues/comments{/number}","contents_url":"https://api.github.com/repos/mjackson/expect/contents/{+path}","compare_url":"https://api.github.com/repos/mjackson/expect/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mjackson/expect/merges","archive_url":"https://api.github.com/repos/mjackson/expect/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mjackson/expect/downloads","issues_url":"https://api.github.com/repos/mjackson/expect/issues{/number}","pulls_url":"https://api.github.com/repos/mjackson/expect/pulls{/number}","milestones_url":"https://api.github.com/repos/mjackson/expect/milestones{/number}","notifications_url":"https://api.github.com/repos/mjackson/expect/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mjackson/expect/labels{/name}","releases_url":"https://api.github.com/repos/mjackson/expect/releases{/id}","created_at":"2014-03-09T22:14:21Z","updated_at":"2015-11-28T00:26:08Z","pushed_at":"2015-11-28T01:04:32Z","git_url":"git://github.com/mjackson/expect.git","ssh_url":"git@github.com:mjackson/expect.git","clone_url":"https://github.com/mjackson/expect.git","svn_url":"https://github.com/mjackson/expect","homepage":"","size":693,"stargazers_count":153,"watchers_count":153,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":4,"forks":13,"open_issues":4,"watchers":153,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mjackson/expect/pulls/48"},"html":{"href":"https://github.com/mjackson/expect/pull/48"},"issue":{"href":"https://api.github.com/repos/mjackson/expect/issues/48"},"comments":{"href":"https://api.github.com/repos/mjackson/expect/issues/48/comments"},"review_comments":{"href":"https://api.github.com/repos/mjackson/expect/pulls/48/comments"},"review_comment":{"href":"https://api.github.com/repos/mjackson/expect/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mjackson/expect/pulls/48/commits"},"statuses":{"href":"https://api.github.com/repos/mjackson/expect/statuses/c406a4a5dea88e5f5639f1107669d0a9d5e4e5d1"}}}}