{"action":"created","comment":{"url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls/comments/38334787","id":38334787,"diff_hunk":"@@ -1,3 +1,105 @@\n+require \"spec_helper\"\n+\n describe Kidoikoi do\n+  before do\n+    @data_base = double(\"data_base\")\n+    allow(@data_base).to receive(:set)\n+    allow(@data_base).to receive(:get)\n+\n+    @kidoikoi = Kidoikoi.new(@data_base)\n+  end\n+\n+  describe \"#split_bill_between\" do\n+    context \"when there is no debt relation between users\" do\n+\n+      context \"when Sacha and Pg split a 9 euros bill with Loic\" do\n+        let(:debtors) {[\"Sacha\", \"PG\"]}\n+        let(:total_value) {9}\n+        let(:creditor) {\"Loic\"}\n+\n+        it \"sets Sacha's and Pg's debt to Loic at 3 euros\" do\n+          @kidoikoi.split_bill_between(debtors, total_value, creditor)\n+          expect(@database).to have_received(:set).with(\"Sacha\", {\"Loic\" => -3})\n+          expect(@database).to have_received(:set).with(\"PG\", {\"Loic\" => -3})\n+          expect(@database).to have_received(:set).with(\"Loic\", {\"Sacha\" => 3, \"PG\" => 3})\n+        end\n+      end\n+\n+      context \"when a negative bill value is given\" do\n+        let(:debtors) {[\"Sacha\", \"PG\"]}\n+        let(:total_value) {-9}\n+        let(:creditor) {\"Loic\"}\n+\n+        it \"raises an error\" do\n+          expect{@kidoikoi.split_bill_between(debtors, total_value, creditor)}.to\n+            raise_error(\"total_value must be strictly positive\")\n+        end\n+      end\n+\n+      context \"when Loic is in debtor and creditor\" do\n+        let(:debtors) {[\"Sacha\", \"PG\", \"Loic\"]}\n+        let(:total_value) {9}\n+        let(:creditor) {\"Loic\"}\n+\n+        it \"raises an error\" do\n+          expect{@kidoikoi.split_bill_between(debtors, total_value, creditor)}.to\n+            raise_error(\"Creditor can't be a debtor\")\n+        end\n+      end\n+    end\n+\n+    context \"when a debt relation between users is already set\" do\n+      before do\n+        allow(@data_base).to receive(:get).with(\"Sacha\").and_return({\"Loic\" => 50})\n+        allow(@data_base).to receive(:get).with(\"Loic\").and_return({\"Sacha\" => -50})\n+      end\n+\n+      context \"when Sacha and Pg split a 23.50 euros bill with Loic\" do\n+        let(:debtors) {[\"Sacha\", \"PG\"]}\n+        let(:total_value) {23.50}\n+        let(:creditor) {\"Loic\"}\n+\n+        it \"adds 7.83 to Sacha's and Pg's debt to Loic\" do\n+          @kidoikoi.split_bill_between(debtors, total_value, creditor)\n+          expect(@database).to have_received(:set).with(\"Sacha\", {\"Loic\" => -57.83})\n+          expect(@database).to have_received(:set).with(\"PG\", {\"Loic\" => -7.83})\n+          expect(@database).to have_received(:set).with(\"Loic\", {\"Sacha\" => 57.83, \"PG\" => 7.83})\n+        end\n+      end\n+    end\n+  end\n+\n+  describe \"#resume_debt\" do\n+    context \"when there is no debt relation between users\" do\n+","path":"spec/lita/kidoikoi_spec.rb","position":76,"original_position":74,"commit_id":"510bf5fa0649067f1bbd827bacb3d97c64f928c3","original_commit_id":"61a47047e56e112b4750a3444f8a43c19001f905","user":{"login":"pgtamatoa","id":11528882,"avatar_url":"https://avatars.githubusercontent.com/u/11528882?v=3","gravatar_id":"","url":"https://api.github.com/users/pgtamatoa","html_url":"https://github.com/pgtamatoa","followers_url":"https://api.github.com/users/pgtamatoa/followers","following_url":"https://api.github.com/users/pgtamatoa/following{/other_user}","gists_url":"https://api.github.com/users/pgtamatoa/gists{/gist_id}","starred_url":"https://api.github.com/users/pgtamatoa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pgtamatoa/subscriptions","organizations_url":"https://api.github.com/users/pgtamatoa/orgs","repos_url":"https://api.github.com/users/pgtamatoa/repos","events_url":"https://api.github.com/users/pgtamatoa/events{/privacy}","received_events_url":"https://api.github.com/users/pgtamatoa/received_events","type":"User","site_admin":false},"body":"(Saut de ligne)\r\n","created_at":"2015-08-31T17:19:30Z","updated_at":"2015-08-31T17:19:30Z","html_url":"https://github.com/sal-himd/lita-kidoikoi/pull/1#discussion_r38334787","pull_request_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls/comments/38334787"},"html":{"href":"https://github.com/sal-himd/lita-kidoikoi/pull/1#discussion_r38334787"},"pull_request":{"href":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls/1","id":43751292,"html_url":"https://github.com/sal-himd/lita-kidoikoi/pull/1","diff_url":"https://github.com/sal-himd/lita-kidoikoi/pull/1.diff","patch_url":"https://github.com/sal-himd/lita-kidoikoi/pull/1.patch","issue_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/issues/1","number":1,"state":"open","locked":false,"title":"Development","user":{"login":"sal-himd","id":12863338,"avatar_url":"https://avatars.githubusercontent.com/u/12863338?v=3","gravatar_id":"","url":"https://api.github.com/users/sal-himd","html_url":"https://github.com/sal-himd","followers_url":"https://api.github.com/users/sal-himd/followers","following_url":"https://api.github.com/users/sal-himd/following{/other_user}","gists_url":"https://api.github.com/users/sal-himd/gists{/gist_id}","starred_url":"https://api.github.com/users/sal-himd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sal-himd/subscriptions","organizations_url":"https://api.github.com/users/sal-himd/orgs","repos_url":"https://api.github.com/users/sal-himd/repos","events_url":"https://api.github.com/users/sal-himd/events{/privacy}","received_events_url":"https://api.github.com/users/sal-himd/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-31T10:31:47Z","updated_at":"2015-08-31T17:19:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d11a85ad8e6cd75eaba49c6392dcba39e3e52304","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls/1/commits","review_comments_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls/1/comments","review_comment_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/issues/1/comments","statuses_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/statuses/510bf5fa0649067f1bbd827bacb3d97c64f928c3","head":{"label":"sal-himd:development","ref":"development","sha":"510bf5fa0649067f1bbd827bacb3d97c64f928c3","user":{"login":"sal-himd","id":12863338,"avatar_url":"https://avatars.githubusercontent.com/u/12863338?v=3","gravatar_id":"","url":"https://api.github.com/users/sal-himd","html_url":"https://github.com/sal-himd","followers_url":"https://api.github.com/users/sal-himd/followers","following_url":"https://api.github.com/users/sal-himd/following{/other_user}","gists_url":"https://api.github.com/users/sal-himd/gists{/gist_id}","starred_url":"https://api.github.com/users/sal-himd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sal-himd/subscriptions","organizations_url":"https://api.github.com/users/sal-himd/orgs","repos_url":"https://api.github.com/users/sal-himd/repos","events_url":"https://api.github.com/users/sal-himd/events{/privacy}","received_events_url":"https://api.github.com/users/sal-himd/received_events","type":"User","site_admin":false},"repo":{"id":41551986,"name":"lita-kidoikoi","full_name":"sal-himd/lita-kidoikoi","owner":{"login":"sal-himd","id":12863338,"avatar_url":"https://avatars.githubusercontent.com/u/12863338?v=3","gravatar_id":"","url":"https://api.github.com/users/sal-himd","html_url":"https://github.com/sal-himd","followers_url":"https://api.github.com/users/sal-himd/followers","following_url":"https://api.github.com/users/sal-himd/following{/other_user}","gists_url":"https://api.github.com/users/sal-himd/gists{/gist_id}","starred_url":"https://api.github.com/users/sal-himd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sal-himd/subscriptions","organizations_url":"https://api.github.com/users/sal-himd/orgs","repos_url":"https://api.github.com/users/sal-himd/repos","events_url":"https://api.github.com/users/sal-himd/events{/privacy}","received_events_url":"https://api.github.com/users/sal-himd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sal-himd/lita-kidoikoi","description":"Lita plugin for splitting bills between coworkers","fork":true,"url":"https://api.github.com/repos/sal-himd/lita-kidoikoi","forks_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/forks","keys_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/teams","hooks_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/hooks","issue_events_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/issues/events{/number}","events_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/events","assignees_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/assignees{/user}","branches_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/branches{/branch}","tags_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/tags","blobs_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/git/refs{/sha}","trees_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/statuses/{sha}","languages_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/languages","stargazers_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/stargazers","contributors_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/contributors","subscribers_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/subscribers","subscription_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/subscription","commits_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/commits{/sha}","git_commits_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/git/commits{/sha}","comments_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/comments{/number}","issue_comment_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/issues/comments{/number}","contents_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/contents/{+path}","compare_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/merges","archive_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/downloads","issues_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/issues{/number}","pulls_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls{/number}","milestones_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/milestones{/number}","notifications_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/labels{/name}","releases_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/releases{/id}","created_at":"2015-08-28T14:35:03Z","updated_at":"2015-08-28T14:35:04Z","pushed_at":"2015-08-31T17:08:24Z","git_url":"git://github.com/sal-himd/lita-kidoikoi.git","ssh_url":"git@github.com:sal-himd/lita-kidoikoi.git","clone_url":"https://github.com/sal-himd/lita-kidoikoi.git","svn_url":"https://github.com/sal-himd/lita-kidoikoi","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"sal-himd:master","ref":"master","sha":"efb52344db9f2f95332a9eab282ced36ea534b85","user":{"login":"sal-himd","id":12863338,"avatar_url":"https://avatars.githubusercontent.com/u/12863338?v=3","gravatar_id":"","url":"https://api.github.com/users/sal-himd","html_url":"https://github.com/sal-himd","followers_url":"https://api.github.com/users/sal-himd/followers","following_url":"https://api.github.com/users/sal-himd/following{/other_user}","gists_url":"https://api.github.com/users/sal-himd/gists{/gist_id}","starred_url":"https://api.github.com/users/sal-himd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sal-himd/subscriptions","organizations_url":"https://api.github.com/users/sal-himd/orgs","repos_url":"https://api.github.com/users/sal-himd/repos","events_url":"https://api.github.com/users/sal-himd/events{/privacy}","received_events_url":"https://api.github.com/users/sal-himd/received_events","type":"User","site_admin":false},"repo":{"id":41551986,"name":"lita-kidoikoi","full_name":"sal-himd/lita-kidoikoi","owner":{"login":"sal-himd","id":12863338,"avatar_url":"https://avatars.githubusercontent.com/u/12863338?v=3","gravatar_id":"","url":"https://api.github.com/users/sal-himd","html_url":"https://github.com/sal-himd","followers_url":"https://api.github.com/users/sal-himd/followers","following_url":"https://api.github.com/users/sal-himd/following{/other_user}","gists_url":"https://api.github.com/users/sal-himd/gists{/gist_id}","starred_url":"https://api.github.com/users/sal-himd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sal-himd/subscriptions","organizations_url":"https://api.github.com/users/sal-himd/orgs","repos_url":"https://api.github.com/users/sal-himd/repos","events_url":"https://api.github.com/users/sal-himd/events{/privacy}","received_events_url":"https://api.github.com/users/sal-himd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sal-himd/lita-kidoikoi","description":"Lita plugin for splitting bills between coworkers","fork":true,"url":"https://api.github.com/repos/sal-himd/lita-kidoikoi","forks_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/forks","keys_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/teams","hooks_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/hooks","issue_events_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/issues/events{/number}","events_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/events","assignees_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/assignees{/user}","branches_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/branches{/branch}","tags_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/tags","blobs_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/git/refs{/sha}","trees_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/statuses/{sha}","languages_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/languages","stargazers_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/stargazers","contributors_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/contributors","subscribers_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/subscribers","subscription_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/subscription","commits_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/commits{/sha}","git_commits_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/git/commits{/sha}","comments_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/comments{/number}","issue_comment_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/issues/comments{/number}","contents_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/contents/{+path}","compare_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/merges","archive_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/downloads","issues_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/issues{/number}","pulls_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls{/number}","milestones_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/milestones{/number}","notifications_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/labels{/name}","releases_url":"https://api.github.com/repos/sal-himd/lita-kidoikoi/releases{/id}","created_at":"2015-08-28T14:35:03Z","updated_at":"2015-08-28T14:35:04Z","pushed_at":"2015-08-31T17:08:24Z","git_url":"git://github.com/sal-himd/lita-kidoikoi.git","ssh_url":"git@github.com:sal-himd/lita-kidoikoi.git","clone_url":"https://github.com/sal-himd/lita-kidoikoi.git","svn_url":"https://github.com/sal-himd/lita-kidoikoi","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls/1"},"html":{"href":"https://github.com/sal-himd/lita-kidoikoi/pull/1"},"issue":{"href":"https://api.github.com/repos/sal-himd/lita-kidoikoi/issues/1"},"comments":{"href":"https://api.github.com/repos/sal-himd/lita-kidoikoi/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sal-himd/lita-kidoikoi/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/sal-himd/lita-kidoikoi/statuses/510bf5fa0649067f1bbd827bacb3d97c64f928c3"}}}}