GitHub PullRequestReviewCommentEvent at 2014-08-12 18:47:47
Repository: mutator
Actor: houndci
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/ericroberts/mutator/pulls/comments/16133856","id":16133856,"diff_hunk":"@@ -0,0 +1,162 @@\n+require 'spec_helper'\n+require 'mutator'\n+\n+class Stateholder\n+  attr_writer :state\n+\n+  def state\n+    @state ||= :initial_state\n+  end\n+end\n+\n+module Mutator\n+  class Stateholder < Machine\n+    def self.transitions\n+      [\n+        { from: [:initial_state], to: :second_state },\n+        { from: [:second_state], to: :third_state }\n+      ]\n+    end\n+  end\n+end\n+\n+describe Mutator::Stateholder do\n+  subject { Mutator::Stateholder.new(stateholder) }\n+  let(:stateholder) { Stateholder.new }\n+\n+  describe '#initialize' do\n+    it 'should not error' do\n+      expect { subject }.to_not raise_error\n+    end\n+  end\n+\n+  describe '#stateholder' do\n+    it 'should return the stateholder it was passed' do\n+      expect(subject.stateholder).to eq stateholder\n+    end\n+  end\n+\n+  describe '#valid?' do\n+    it 'should be valid if the state exists in states list' do\n+      subject.stateholder.state = :initial_state\n+      expect(subject).to be_valid\n+    end\n+\n+    it 'should not be valid for a state not in states list' do\n+      subject.stateholder.state = :foobar\n+      expect(subject).to_not be_valid\n+    end\n+  end\n+\n+  describe '#current_state' do\n+    it 'should return the stateholder state' do\n+      expect(subject.current_state).to eq stateholder.state\n+    end\n+  end\n+\n+  describe '#transition' do\n+    context 'valid transition' do\n+      let(:from) { :initial_state }\n+      let(:to) { :second_state }\n+\n+      before { subject.stateholder.state = from }\n+\n+      it 'should update state' do\n+        expect(subject.stateholder.state).to eq from\n+        subject.transition(to: to)\n+        expect(subject.stateholder.state).to eq to\n+      end\n+\n+      it 'should return true' do\n+        expect(subject.transition(to: to)).to be true\n+      end\n+\n+      context 'with success policy' do\n+        let(:success) { double }\n+\n+        before { allow(success).to receive(:call).and_return(true) }\n+\n+        it 'should still update state' do\n+          expect(subject.stateholder.state).to eq from\n+          subject.transition(to: to, success: success)\n+          expect(subject.stateholder.state).to eq to\n+        end\n+\n+        it 'should still return true' do\n+          expect(subject.transition(to: to, success: success)).to be true\n+        end\n+\n+        it 'should call the success policy' do\n+          expect(success).to receive(:call).and_return(true)\n+          subject.transition(to: to, success: success)\n+        end\n+      end\n+    end\n+\n+    context 'invalid transition' do\n+      let(:from) { :initial_state }\n+      let(:to) { :third_state }\n+\n+      before { subject.stateholder.state = from }\n+\n+      it 'should not update state' do\n+        expect(subject.stateholder.state).to eq from\n+        subject.transition(to: to)\n+        expect(subject.stateholder.state).to eq from\n+      end\n+\n+      it 'should return false' do\n+        expect(subject.transition(to: to)).to be false\n+      end\n+\n+      context 'with failure policy' do\n+        let(:failure) { double }\n+\n+        before { allow(failure).to receive(:call).and_return(true) }\n+\n+        it 'should still not update state' do\n+          expect(subject.stateholder.state).to eq from\n+          subject.transition(to: to, failure: failure)\n+          expect(subject.stateholder.state).to eq from\n+        end\n+\n+        it 'should still return false' do\n+          expect(subject.transition(to: to, failure: failure)).to be false\n+        end\n+\n+        it 'should call the failure policy' do\n+          expect(failure).to receive(:call).and_return(true)\n+          subject.transition(to: to, failure: failure)\n+        end\n+\n+        context 'when policy is to raise an exception' do\n+          before { expect(failure).to receive(:call).and_raise(Exception) }\n+          \n+          it 'should raise an exception' do\n+            expect { subject.transition(to: to, failure: failure) }.to raise_error Exception","path":"spec/lib/mutator/machine_spec.rb","position":136,"original_position":136,"commit_id":"48cb5863fc9be31d8bb0346c0ed69f5d26ff8774","original_commit_id":"48cb5863fc9be31d8bb0346c0ed69f5d26ff8774","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=2","gravatar_id":"38d9cefd9971a05bf447f07c6cd332cc","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Line is too long. [92/80]","created_at":"2014-08-12T18:47:47Z","updated_at":"2014-08-12T18:47:47Z","html_url":"https://github.com/ericroberts/mutator/pull/1#discussion_r16133856","pull_request_url":"https://api.github.com/repos/ericroberts/mutator/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/ericroberts/mutator/pulls/comments/16133856"},"html":{"href":"https://github.com/ericroberts/mutator/pull/1#discussion_r16133856"},"pull_request":{"href":"https://api.github.com/repos/ericroberts/mutator/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/ericroberts/mutator/pulls/1","id":19679250,"html_url":"https://github.com/ericroberts/mutator/pull/1","diff_url":"https://github.com/ericroberts/mutator/pull/1.diff","patch_url":"https://github.com/ericroberts/mutator/pull/1.patch","issue_url":"https://api.github.com/repos/ericroberts/mutator/issues/1","number":1,"state":"open","title":"Add some tests.","user":{"login":"ericroberts","id":695547,"avatar_url":"https://avatars.githubusercontent.com/u/695547?v=2","gravatar_id":"f4e3457a0d1c8a537b7907420e1fa254","url":"https://api.github.com/users/ericroberts","html_url":"https://github.com/ericroberts","followers_url":"https://api.github.com/users/ericroberts/followers","following_url":"https://api.github.com/users/ericroberts/following{/other_user}","gists_url":"https://api.github.com/users/ericroberts/gists{/gist_id}","starred_url":"https://api.github.com/users/ericroberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericroberts/subscriptions","organizations_url":"https://api.github.com/users/ericroberts/orgs","repos_url":"https://api.github.com/users/ericroberts/repos","events_url":"https://api.github.com/users/ericroberts/events{/privacy}","received_events_url":"https://api.github.com/users/ericroberts/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-08-12T18:13:30Z","updated_at":"2014-08-12T18:47:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2daba7977244bfc2351555126845edde30516481","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ericroberts/mutator/pulls/1/commits","review_comments_url":"https://api.github.com/repos/ericroberts/mutator/pulls/1/comments","review_comment_url":"https://api.github.com/repos/ericroberts/mutator/pulls/comments/{number}","comments_url":"https://api.github.com/repos/ericroberts/mutator/issues/1/comments","statuses_url":"https://api.github.com/repos/ericroberts/mutator/statuses/48cb5863fc9be31d8bb0346c0ed69f5d26ff8774","head":{"label":"ericroberts:add-tests","ref":"add-tests","sha":"48cb5863fc9be31d8bb0346c0ed69f5d26ff8774","user":{"login":"ericroberts","id":695547,"avatar_url":"https://avatars.githubusercontent.com/u/695547?v=2","gravatar_id":"f4e3457a0d1c8a537b7907420e1fa254","url":"https://api.github.com/users/ericroberts","html_url":"https://github.com/ericroberts","followers_url":"https://api.github.com/users/ericroberts/followers","following_url":"https://api.github.com/users/ericroberts/following{/other_user}","gists_url":"https://api.github.com/users/ericroberts/gists{/gist_id}","starred_url":"https://api.github.com/users/ericroberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericroberts/subscriptions","organizations_url":"https://api.github.com/users/ericroberts/orgs","repos_url":"https://api.github.com/users/ericroberts/repos","events_url":"https://api.github.com/users/ericroberts/events{/privacy}","received_events_url":"https://api.github.com/users/ericroberts/received_events","type":"User","site_admin":false},"repo":{"id":22776939,"name":"mutator","full_name":"ericroberts/mutator","owner":{"login":"ericroberts","id":695547,"avatar_url":"https://avatars.githubusercontent.com/u/695547?v=2","gravatar_id":"f4e3457a0d1c8a537b7907420e1fa254","url":"https://api.github.com/users/ericroberts","html_url":"https://github.com/ericroberts","followers_url":"https://api.github.com/users/ericroberts/followers","following_url":"https://api.github.com/users/ericroberts/following{/other_user}","gists_url":"https://api.github.com/users/ericroberts/gists{/gist_id}","starred_url":"https://api.github.com/users/ericroberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericroberts/subscriptions","organizations_url":"https://api.github.com/users/ericroberts/orgs","repos_url":"https://api.github.com/users/ericroberts/repos","events_url":"https://api.github.com/users/ericroberts/events{/privacy}","received_events_url":"https://api.github.com/users/ericroberts/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ericroberts/mutator","description":"Mutator is just another state machine gem.","fork":false,"url":"https://api.github.com/repos/ericroberts/mutator","forks_url":"https://api.github.com/repos/ericroberts/mutator/forks","keys_url":"https://api.github.com/repos/ericroberts/mutator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ericroberts/mutator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ericroberts/mutator/teams","hooks_url":"https://api.github.com/repos/ericroberts/mutator/hooks","issue_events_url":"https://api.github.com/repos/ericroberts/mutator/issues/events{/number}","events_url":"https://api.github.com/repos/ericroberts/mutator/events","assignees_url":"https://api.github.com/repos/ericroberts/mutator/assignees{/user}","branches_url":"https://api.github.com/repos/ericroberts/mutator/branches{/branch}","tags_url":"https://api.github.com/repos/ericroberts/mutator/tags","blobs_url":"https://api.github.com/repos/ericroberts/mutator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ericroberts/mutator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ericroberts/mutator/git/refs{/sha}","trees_url":"https://api.github.com/repos/ericroberts/mutator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ericroberts/mutator/statuses/{sha}","languages_url":"https://api.github.com/repos/ericroberts/mutator/languages","stargazers_url":"https://api.github.com/repos/ericroberts/mutator/stargazers","contributors_url":"https://api.github.com/repos/ericroberts/mutator/contributors","subscribers_url":"https://api.github.com/repos/ericroberts/mutator/subscribers","subscription_url":"https://api.github.com/repos/ericroberts/mutator/subscription","commits_url":"https://api.github.com/repos/ericroberts/mutator/commits{/sha}","git_commits_url":"https://api.github.com/repos/ericroberts/mutator/git/commits{/sha}","comments_url":"https://api.github.com/repos/ericroberts/mutator/comments{/number}","issue_comment_url":"https://api.github.com/repos/ericroberts/mutator/issues/comments/{number}","contents_url":"https://api.github.com/repos/ericroberts/mutator/contents/{+path}","compare_url":"https://api.github.com/repos/ericroberts/mutator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ericroberts/mutator/merges","archive_url":"https://api.github.com/repos/ericroberts/mutator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ericroberts/mutator/downloads","issues_url":"https://api.github.com/repos/ericroberts/mutator/issues{/number}","pulls_url":"https://api.github.com/repos/ericroberts/mutator/pulls{/number}","milestones_url":"https://api.github.com/repos/ericroberts/mutator/milestones{/number}","notifications_url":"https://api.github.com/repos/ericroberts/mutator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ericroberts/mutator/labels{/name}","releases_url":"https://api.github.com/repos/ericroberts/mutator/releases{/id}","created_at":"2014-08-09T02:25:15Z","updated_at":"2014-08-09T02:25:49Z","pushed_at":"2014-08-12T18:47:36Z","git_url":"git://github.com/ericroberts/mutator.git","ssh_url":"git@github.com:ericroberts/mutator.git","clone_url":"https://github.com/ericroberts/mutator.git","svn_url":"https://github.com/ericroberts/mutator","homepage":"","size":0,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"ericroberts:master","ref":"master","sha":"cb745589fad06583370367709fa9cac2be1bd61b","user":{"login":"ericroberts","id":695547,"avatar_url":"https://avatars.githubusercontent.com/u/695547?v=2","gravatar_id":"f4e3457a0d1c8a537b7907420e1fa254","url":"https://api.github.com/users/ericroberts","html_url":"https://github.com/ericroberts","followers_url":"https://api.github.com/users/ericroberts/followers","following_url":"https://api.github.com/users/ericroberts/following{/other_user}","gists_url":"https://api.github.com/users/ericroberts/gists{/gist_id}","starred_url":"https://api.github.com/users/ericroberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericroberts/subscriptions","organizations_url":"https://api.github.com/users/ericroberts/orgs","repos_url":"https://api.github.com/users/ericroberts/repos","events_url":"https://api.github.com/users/ericroberts/events{/privacy}","received_events_url":"https://api.github.com/users/ericroberts/received_events","type":"User","site_admin":false},"repo":{"id":22776939,"name":"mutator","full_name":"ericroberts/mutator","owner":{"login":"ericroberts","id":695547,"avatar_url":"https://avatars.githubusercontent.com/u/695547?v=2","gravatar_id":"f4e3457a0d1c8a537b7907420e1fa254","url":"https://api.github.com/users/ericroberts","html_url":"https://github.com/ericroberts","followers_url":"https://api.github.com/users/ericroberts/followers","following_url":"https://api.github.com/users/ericroberts/following{/other_user}","gists_url":"https://api.github.com/users/ericroberts/gists{/gist_id}","starred_url":"https://api.github.com/users/ericroberts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericroberts/subscriptions","organizations_url":"https://api.github.com/users/ericroberts/orgs","repos_url":"https://api.github.com/users/ericroberts/repos","events_url":"https://api.github.com/users/ericroberts/events{/privacy}","received_events_url":"https://api.github.com/users/ericroberts/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ericroberts/mutator","description":"Mutator is just another state machine gem.","fork":false,"url":"https://api.github.com/repos/ericroberts/mutator","forks_url":"https://api.github.com/repos/ericroberts/mutator/forks","keys_url":"https://api.github.com/repos/ericroberts/mutator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ericroberts/mutator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ericroberts/mutator/teams","hooks_url":"https://api.github.com/repos/ericroberts/mutator/hooks","issue_events_url":"https://api.github.com/repos/ericroberts/mutator/issues/events{/number}","events_url":"https://api.github.com/repos/ericroberts/mutator/events","assignees_url":"https://api.github.com/repos/ericroberts/mutator/assignees{/user}","branches_url":"https://api.github.com/repos/ericroberts/mutator/branches{/branch}","tags_url":"https://api.github.com/repos/ericroberts/mutator/tags","blobs_url":"https://api.github.com/repos/ericroberts/mutator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ericroberts/mutator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ericroberts/mutator/git/refs{/sha}","trees_url":"https://api.github.com/repos/ericroberts/mutator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ericroberts/mutator/statuses/{sha}","languages_url":"https://api.github.com/repos/ericroberts/mutator/languages","stargazers_url":"https://api.github.com/repos/ericroberts/mutator/stargazers","contributors_url":"https://api.github.com/repos/ericroberts/mutator/contributors","subscribers_url":"https://api.github.com/repos/ericroberts/mutator/subscribers","subscription_url":"https://api.github.com/repos/ericroberts/mutator/subscription","commits_url":"https://api.github.com/repos/ericroberts/mutator/commits{/sha}","git_commits_url":"https://api.github.com/repos/ericroberts/mutator/git/commits{/sha}","comments_url":"https://api.github.com/repos/ericroberts/mutator/comments{/number}","issue_comment_url":"https://api.github.com/repos/ericroberts/mutator/issues/comments/{number}","contents_url":"https://api.github.com/repos/ericroberts/mutator/contents/{+path}","compare_url":"https://api.github.com/repos/ericroberts/mutator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ericroberts/mutator/merges","archive_url":"https://api.github.com/repos/ericroberts/mutator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ericroberts/mutator/downloads","issues_url":"https://api.github.com/repos/ericroberts/mutator/issues{/number}","pulls_url":"https://api.github.com/repos/ericroberts/mutator/pulls{/number}","milestones_url":"https://api.github.com/repos/ericroberts/mutator/milestones{/number}","notifications_url":"https://api.github.com/repos/ericroberts/mutator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ericroberts/mutator/labels{/name}","releases_url":"https://api.github.com/repos/ericroberts/mutator/releases{/id}","created_at":"2014-08-09T02:25:15Z","updated_at":"2014-08-09T02:25:49Z","pushed_at":"2014-08-12T18:47:36Z","git_url":"git://github.com/ericroberts/mutator.git","ssh_url":"git@github.com:ericroberts/mutator.git","clone_url":"https://github.com/ericroberts/mutator.git","svn_url":"https://github.com/ericroberts/mutator","homepage":"","size":0,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"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/ericroberts/mutator/pulls/1"},"html":{"href":"https://github.com/ericroberts/mutator/pull/1"},"issue":{"href":"https://api.github.com/repos/ericroberts/mutator/issues/1"},"comments":{"href":"https://api.github.com/repos/ericroberts/mutator/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/ericroberts/mutator/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/ericroberts/mutator/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/ericroberts/mutator/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/ericroberts/mutator/statuses/48cb5863fc9be31d8bb0346c0ed69f5d26ff8774"}}}}