{"action":"created","comment":{"url":"https://api.github.com/repos/wagn/wikirate/pulls/comments/58279053","id":58279053,"diff_hunk":"@@ -0,0 +1,138 @@\n+# -*- encoding : utf-8 -*-\n+\n+describe Card::Set::MetricType::Formula do\n+  before do\n+    @name = 'Jedi+friendliness'\n+  end\n+  let(:metric) { Card[@name] }\n+  describe '#metric_type' do\n+    subject { metric.metric_type }\n+    it { is_expected.to eq 'Formula' }\n+  end\n+  describe '#metric_type_codename' do\n+    subject { metric.metric_type_codename }\n+    it { is_expected.to eq :formula }\n+  end\n+  describe '#metric_designer' do\n+    subject { metric.metric_designer }\n+    it { is_expected.to eq 'Jedi' }\n+  end\n+  describe '#metric_designer_card' do\n+    subject { metric.metric_designer_card }\n+    it { is_expected.to eq Card['Jedi'] }\n+  end\n+  describe '#metric_title' do\n+    subject { metric.metric_title }\n+    it { is_expected.to eq 'friendliness' }\n+  end\n+  describe '#metric_title_card' do\n+    subject { metric.metric_title_card }\n+    it { is_expected.to eq Card['friendliness'] }\n+  end\n+  describe '#question_card' do\n+    subject { metric.question_card.name }\n+    it { is_expected.to eq 'Jedi+friendliness+Question'}\n+  end\n+  describe '#value_type' do\n+    subject { metric.value_type }\n+    it { is_expected.to eq 'Number' }\n+  end\n+  describe '#categorical?' do\n+    subject { metric.categorical? }\n+    it { is_expected.to be_falsey }\n+  end\n+  describe '#researched?' do\n+    subject { metric.researched? }\n+    it { is_expected.to be_falsey }\n+  end\n+  describe '#scored?' do\n+    subject { metric.scored? }\n+    it { is_expected.to be_falsey }\n+  end\n+\n+  def calc_value company='Samsung', year='2014'\n+    rating_value_card(company, year).content\n+  end\n+\n+  def calc_value_card company='Samsung', year='2014'\n+    Card[\"Joe User+rating1+#{company}+#{year}+value\"]\n+  end\n+\n+  before do\n+    @metric = create_metric(\n+      name: 'formula1', type: :formula,\n+      formula: '{{Joe User+score1}}*5+{{Joe User+score2}}*2'\n+    )\n+  end\n+\n+  context 'when created with formula' do\n+    it 'creates calculated values' do\n+      expect(calc_value).to eq('60')\n+      expect(calc_value 'Samsung', '2015').to eq('29')\n+      expect(calc_value 'Sony_Corporation').to eq('9')\n+      expect(rating_value_card 'Death_Star', '1977').to be_falsey\n+    end\n+  end\n+\n+  context 'when created without formula' do\n+    before do\n+      @metric = create_metric name: 'formula2', type: :formula\n+    end\n+\n+    it 'creates calculated values if formula created' do\n+      Card::Auth.as_bot do\n+        Card[\"#{@metric.name}+formula\"].update_attributes!(\n+          type_id: Card::PlainTextID,\n+          content: '{{Joe User+score1}}*5+{{Joe User+score2}}*2'\n+        )\n+      end\n+      expect(calc_value).to eq('60')\n+      expect(calc_value 'Samsung', '2015').to eq('29')\n+      expect(calc_value 'Sony_Corporation').to eq('9')\n+      expect(rating_value_card 'Death_Star', '1977').to be_falsey\n+    end\n+  end\n+\n+  context 'when formula changes' do\n+    def update_formula new_formula\n+      Card::Auth.as_bot do\n+        @metric.formula_card.update_attributes! content: new_formula\n+      end\n+    end\n+    it 'updates existing calculated value' do\n+      update_formula '{{Joe User+score1}}*4+{{Joe User+score2}}*2'\n+      expect(rating_value).to eq '50'\n+    end\n+    it 'removes incomplete calculated value' do\n+      update_formula '{{Joe User+score1}}*5+{{Joe User+score2}}*2+{{Joe User+score3}}'\n+      expect(rating_value_card 'Sony_Corporation', '2014').to be_falsey\n+    end\n+    it 'adds complete calculated value' do\n+      update_formula '{{Joe User+score1}}*5'\n+      expect(rating_value 'Death Star', '1977').to eq('25')","path":"mod/01_rating/spec/set/metric_type/formula_spec.rb","position":112,"original_position":112,"commit_id":"1f39c6767e0d661bec979de2348095041852737c","original_commit_id":"1f39c6767e0d661bec979de2348095041852737c","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Add parentheses to nested method call `rating_value 'Death Star', '1977'`.","created_at":"2016-04-01T23:00:15Z","updated_at":"2016-04-01T23:00:15Z","html_url":"https://github.com/wagn/wikirate/pull/357#discussion_r58279053","pull_request_url":"https://api.github.com/repos/wagn/wikirate/pulls/357","_links":{"self":{"href":"https://api.github.com/repos/wagn/wikirate/pulls/comments/58279053"},"html":{"href":"https://github.com/wagn/wikirate/pull/357#discussion_r58279053"},"pull_request":{"href":"https://api.github.com/repos/wagn/wikirate/pulls/357"}}},"pull_request":{"url":"https://api.github.com/repos/wagn/wikirate/pulls/357","id":63594595,"html_url":"https://github.com/wagn/wikirate/pull/357","diff_url":"https://github.com/wagn/wikirate/pull/357.diff","patch_url":"https://github.com/wagn/wikirate/pull/357.patch","issue_url":"https://api.github.com/repos/wagn/wikirate/issues/357","number":357,"state":"open","locked":false,"title":"metrics","user":{"login":"xithan","id":13584,"avatar_url":"https://avatars.githubusercontent.com/u/13584?v=3","gravatar_id":"","url":"https://api.github.com/users/xithan","html_url":"https://github.com/xithan","followers_url":"https://api.github.com/users/xithan/followers","following_url":"https://api.github.com/users/xithan/following{/other_user}","gists_url":"https://api.github.com/users/xithan/gists{/gist_id}","starred_url":"https://api.github.com/users/xithan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xithan/subscriptions","organizations_url":"https://api.github.com/users/xithan/orgs","repos_url":"https://api.github.com/users/xithan/repos","events_url":"https://api.github.com/users/xithan/events{/privacy}","received_events_url":"https://api.github.com/users/xithan/received_events","type":"User","site_admin":false},"body":"not ready yet","created_at":"2016-03-21T16:41:55Z","updated_at":"2016-04-01T23:00:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"50796a6edd0cb4ae74d169c48dd88de7ccc04206","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wagn/wikirate/pulls/357/commits","review_comments_url":"https://api.github.com/repos/wagn/wikirate/pulls/357/comments","review_comment_url":"https://api.github.com/repos/wagn/wikirate/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wagn/wikirate/issues/357/comments","statuses_url":"https://api.github.com/repos/wagn/wikirate/statuses/1f39c6767e0d661bec979de2348095041852737c","head":{"label":"xithan:all_metrics","ref":"all_metrics","sha":"1f39c6767e0d661bec979de2348095041852737c","user":{"login":"xithan","id":13584,"avatar_url":"https://avatars.githubusercontent.com/u/13584?v=3","gravatar_id":"","url":"https://api.github.com/users/xithan","html_url":"https://github.com/xithan","followers_url":"https://api.github.com/users/xithan/followers","following_url":"https://api.github.com/users/xithan/following{/other_user}","gists_url":"https://api.github.com/users/xithan/gists{/gist_id}","starred_url":"https://api.github.com/users/xithan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xithan/subscriptions","organizations_url":"https://api.github.com/users/xithan/orgs","repos_url":"https://api.github.com/users/xithan/repos","events_url":"https://api.github.com/users/xithan/events{/privacy}","received_events_url":"https://api.github.com/users/xithan/received_events","type":"User","site_admin":false},"repo":{"id":20190741,"name":"wikirate","full_name":"xithan/wikirate","owner":{"login":"xithan","id":13584,"avatar_url":"https://avatars.githubusercontent.com/u/13584?v=3","gravatar_id":"","url":"https://api.github.com/users/xithan","html_url":"https://github.com/xithan","followers_url":"https://api.github.com/users/xithan/followers","following_url":"https://api.github.com/users/xithan/following{/other_user}","gists_url":"https://api.github.com/users/xithan/gists{/gist_id}","starred_url":"https://api.github.com/users/xithan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xithan/subscriptions","organizations_url":"https://api.github.com/users/xithan/orgs","repos_url":"https://api.github.com/users/xithan/repos","events_url":"https://api.github.com/users/xithan/events{/privacy}","received_events_url":"https://api.github.com/users/xithan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xithan/wikirate","description":"","fork":true,"url":"https://api.github.com/repos/xithan/wikirate","forks_url":"https://api.github.com/repos/xithan/wikirate/forks","keys_url":"https://api.github.com/repos/xithan/wikirate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xithan/wikirate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xithan/wikirate/teams","hooks_url":"https://api.github.com/repos/xithan/wikirate/hooks","issue_events_url":"https://api.github.com/repos/xithan/wikirate/issues/events{/number}","events_url":"https://api.github.com/repos/xithan/wikirate/events","assignees_url":"https://api.github.com/repos/xithan/wikirate/assignees{/user}","branches_url":"https://api.github.com/repos/xithan/wikirate/branches{/branch}","tags_url":"https://api.github.com/repos/xithan/wikirate/tags","blobs_url":"https://api.github.com/repos/xithan/wikirate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xithan/wikirate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xithan/wikirate/git/refs{/sha}","trees_url":"https://api.github.com/repos/xithan/wikirate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xithan/wikirate/statuses/{sha}","languages_url":"https://api.github.com/repos/xithan/wikirate/languages","stargazers_url":"https://api.github.com/repos/xithan/wikirate/stargazers","contributors_url":"https://api.github.com/repos/xithan/wikirate/contributors","subscribers_url":"https://api.github.com/repos/xithan/wikirate/subscribers","subscription_url":"https://api.github.com/repos/xithan/wikirate/subscription","commits_url":"https://api.github.com/repos/xithan/wikirate/commits{/sha}","git_commits_url":"https://api.github.com/repos/xithan/wikirate/git/commits{/sha}","comments_url":"https://api.github.com/repos/xithan/wikirate/comments{/number}","issue_comment_url":"https://api.github.com/repos/xithan/wikirate/issues/comments{/number}","contents_url":"https://api.github.com/repos/xithan/wikirate/contents/{+path}","compare_url":"https://api.github.com/repos/xithan/wikirate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xithan/wikirate/merges","archive_url":"https://api.github.com/repos/xithan/wikirate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xithan/wikirate/downloads","issues_url":"https://api.github.com/repos/xithan/wikirate/issues{/number}","pulls_url":"https://api.github.com/repos/xithan/wikirate/pulls{/number}","milestones_url":"https://api.github.com/repos/xithan/wikirate/milestones{/number}","notifications_url":"https://api.github.com/repos/xithan/wikirate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xithan/wikirate/labels{/name}","releases_url":"https://api.github.com/repos/xithan/wikirate/releases{/id}","deployments_url":"https://api.github.com/repos/xithan/wikirate/deployments","created_at":"2014-05-26T15:35:11Z","updated_at":"2016-01-12T14:06:08Z","pushed_at":"2016-04-01T23:00:00Z","git_url":"git://github.com/xithan/wikirate.git","ssh_url":"git@github.com:xithan/wikirate.git","clone_url":"https://github.com/xithan/wikirate.git","svn_url":"https://github.com/xithan/wikirate","homepage":null,"size":85365,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"wagn:master","ref":"master","sha":"1326e4b95c0a14a37d95b2b2487cdf87fcc802b7","user":{"login":"wagn","id":20722,"avatar_url":"https://avatars.githubusercontent.com/u/20722?v=3","gravatar_id":"","url":"https://api.github.com/users/wagn","html_url":"https://github.com/wagn","followers_url":"https://api.github.com/users/wagn/followers","following_url":"https://api.github.com/users/wagn/following{/other_user}","gists_url":"https://api.github.com/users/wagn/gists{/gist_id}","starred_url":"https://api.github.com/users/wagn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wagn/subscriptions","organizations_url":"https://api.github.com/users/wagn/orgs","repos_url":"https://api.github.com/users/wagn/repos","events_url":"https://api.github.com/users/wagn/events{/privacy}","received_events_url":"https://api.github.com/users/wagn/received_events","type":"User","site_admin":false},"repo":{"id":15884166,"name":"wikirate","full_name":"wagn/wikirate","owner":{"login":"wagn","id":20722,"avatar_url":"https://avatars.githubusercontent.com/u/20722?v=3","gravatar_id":"","url":"https://api.github.com/users/wagn","html_url":"https://github.com/wagn","followers_url":"https://api.github.com/users/wagn/followers","following_url":"https://api.github.com/users/wagn/following{/other_user}","gists_url":"https://api.github.com/users/wagn/gists{/gist_id}","starred_url":"https://api.github.com/users/wagn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wagn/subscriptions","organizations_url":"https://api.github.com/users/wagn/orgs","repos_url":"https://api.github.com/users/wagn/repos","events_url":"https://api.github.com/users/wagn/events{/privacy}","received_events_url":"https://api.github.com/users/wagn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wagn/wikirate","description":"","fork":false,"url":"https://api.github.com/repos/wagn/wikirate","forks_url":"https://api.github.com/repos/wagn/wikirate/forks","keys_url":"https://api.github.com/repos/wagn/wikirate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wagn/wikirate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wagn/wikirate/teams","hooks_url":"https://api.github.com/repos/wagn/wikirate/hooks","issue_events_url":"https://api.github.com/repos/wagn/wikirate/issues/events{/number}","events_url":"https://api.github.com/repos/wagn/wikirate/events","assignees_url":"https://api.github.com/repos/wagn/wikirate/assignees{/user}","branches_url":"https://api.github.com/repos/wagn/wikirate/branches{/branch}","tags_url":"https://api.github.com/repos/wagn/wikirate/tags","blobs_url":"https://api.github.com/repos/wagn/wikirate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wagn/wikirate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wagn/wikirate/git/refs{/sha}","trees_url":"https://api.github.com/repos/wagn/wikirate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wagn/wikirate/statuses/{sha}","languages_url":"https://api.github.com/repos/wagn/wikirate/languages","stargazers_url":"https://api.github.com/repos/wagn/wikirate/stargazers","contributors_url":"https://api.github.com/repos/wagn/wikirate/contributors","subscribers_url":"https://api.github.com/repos/wagn/wikirate/subscribers","subscription_url":"https://api.github.com/repos/wagn/wikirate/subscription","commits_url":"https://api.github.com/repos/wagn/wikirate/commits{/sha}","git_commits_url":"https://api.github.com/repos/wagn/wikirate/git/commits{/sha}","comments_url":"https://api.github.com/repos/wagn/wikirate/comments{/number}","issue_comment_url":"https://api.github.com/repos/wagn/wikirate/issues/comments{/number}","contents_url":"https://api.github.com/repos/wagn/wikirate/contents/{+path}","compare_url":"https://api.github.com/repos/wagn/wikirate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wagn/wikirate/merges","archive_url":"https://api.github.com/repos/wagn/wikirate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wagn/wikirate/downloads","issues_url":"https://api.github.com/repos/wagn/wikirate/issues{/number}","pulls_url":"https://api.github.com/repos/wagn/wikirate/pulls{/number}","milestones_url":"https://api.github.com/repos/wagn/wikirate/milestones{/number}","notifications_url":"https://api.github.com/repos/wagn/wikirate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wagn/wikirate/labels{/name}","releases_url":"https://api.github.com/repos/wagn/wikirate/releases{/id}","deployments_url":"https://api.github.com/repos/wagn/wikirate/deployments","created_at":"2014-01-13T22:29:39Z","updated_at":"2016-01-11T16:43:51Z","pushed_at":"2016-04-01T23:00:01Z","git_url":"git://github.com/wagn/wikirate.git","ssh_url":"git@github.com:wagn/wikirate.git","clone_url":"https://github.com/wagn/wikirate.git","svn_url":"https://github.com/wagn/wikirate","homepage":null,"size":85588,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":4,"forks":5,"open_issues":4,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wagn/wikirate/pulls/357"},"html":{"href":"https://github.com/wagn/wikirate/pull/357"},"issue":{"href":"https://api.github.com/repos/wagn/wikirate/issues/357"},"comments":{"href":"https://api.github.com/repos/wagn/wikirate/issues/357/comments"},"review_comments":{"href":"https://api.github.com/repos/wagn/wikirate/pulls/357/comments"},"review_comment":{"href":"https://api.github.com/repos/wagn/wikirate/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wagn/wikirate/pulls/357/commits"},"statuses":{"href":"https://api.github.com/repos/wagn/wikirate/statuses/1f39c6767e0d661bec979de2348095041852737c"}}}}