{"action":"created","comment":{"url":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls/comments/38964697","id":38964697,"diff_hunk":"@@ -1,62 +1,210 @@\n module BlockScore\n   RSpec.describe QuestionSet do\n-    let(:api_stub) { @api_stub }\n     let(:person) { create(:person_params) }\n \n-    it 'create' do\n-      person.question_sets.count\n-      person.question_sets.create\n-      assert_requested(api_stub, times: 2)\n+    describe \"api requests\" do\n+      let(:api_stub) { @api_stub }\n+\n+      context \"when creating\" do\n+        it 'create' do\n+          person.question_sets.count\n+          person.question_sets.create\n+          assert_requested(api_stub, times: 2)\n+        end\n+\n+        it 'create question_set count' do\n+          count = person.question_sets.count\n+          person.question_sets.create\n+          expect(count + 1).to be_truthy\n+          assert_requested(api_stub, times: 2)\n+        end\n+      end\n+\n+      context 'when scoring' do\n+        let(:answers) do\n+            [\n+              { question_id: 1, answer_id: 1 },\n+              { question_id: 2, answer_id: 1 },\n+              { question_id: 3, answer_id: 1 },\n+              { question_id: 4, answer_id: 1 },\n+              { question_id: 5, answer_id: 1 }\n+            ]\n+        end\n+\n+        it 'score call does request' do\n+          qs = person.question_sets.create\n+          qs.score(answers)\n+          assert_requested(api_stub, times: 3)\n+        end\n+      end\n     end\n \n-    it 'create question_set count' do\n-      count = person.question_sets.count\n-      person.question_sets.create\n-      expect(count + 1).to be_truthy\n-      assert_requested(api_stub, times: 2)\n+    describe \"#retrieve\" do\n+\n+      context \"when in person#attributes\" do\n+        let(:qs) { person.question_sets.create }\n+        subject { person.question_sets.retrieve(qs.id) }\n+\n+        it 'loads from collection' do\n+          expect(subject).to eql(qs)\n+        end\n+\n+        it \"retrieves and checks included person data\" do\n+          data = [resource_id]\n+          allow(person.question_sets).to receive(:data) {data}\n+          aggregate_failures(\"retrieves from data\") do\n+            expect(data).to receive(:include?).and_call_original\n+            expect(data).to receive(:[]).and_call_original\n+          end\n+          person.question_sets.retrieve(data[0])\n+        end\n+      end\n+\n+      context \"when not in person#attributes\" do\n+\n+        let(:qs) { QuestionSet.new({person_id: person.id, id: resource_id}) }\n+        let(:data) { person.question_sets.data }\n+        subject { person.question_sets.retrieve(qs.id) }\n+        before(:each) do\n+          person.question_sets.data.clear\n+          allow(QuestionSet).to receive(:retrieve).with(qs.id) { qs }\n+        end\n+\n+\n+        it \"question_sets uses QuestionSet.retrieve\" do\n+          expect(QuestionSet).to receive(:retrieve).with(qs.id) { qs }\n+          expect(subject).to be(qs)\n+        end\n+\n+        it \"registers new question set\" do\n+          aggregate_failures(\"for person and collection\") do\n+            expect(qs).to receive(:id).at_least(:once).and_call_original\n+            expect(person.question_sets).to receive(:<<).with(qs).and_call_original\n+            expect(data).to receive(:<<).with(qs.id).and_call_original\n+          end\n+          person.question_sets.retrieve(qs.id)\n+        end\n+\n+        it \"errors if not belonging\" do\n+          qs.person_id = \"some_not_associated_id\"\n+          expect { subject }.to raise_error(Error, \"None belonging\")\n+        end\n+\n+      end\n     end\n \n-    it 'retrieve' do\n-      qs = person.question_sets.create\n-      person.question_sets.retrieve(qs.id)\n-      assert_requested(api_stub, times: 3)\n+\n+    context \"when id is invalid\" do\n+      pending \"should raise not found if not a resource style id\" do\n+        expect { person.question_sets.retrieve(\"bad_id\") }.to raise_error(NotFoundError)\n+      end\n+\n+      it \"should raise ArgumentError if empty\" do\n+        expect { person.question_sets.retrieve(\"\") }.to raise_error(ArgumentError)\n+      end\n     end\n \n-    describe '#all' do\n-      it 'requests' do\n-        person.question_sets.all\n-        assert_requested(api_stub, times: 2)\n+\n+    describe \"#new\" do\n+\n+      subject { person.question_sets }\n+\n+      it \"should delegate to QuestionSet\" do\n+        expect(QuestionSet).to receive(:new).with(subject.default_params).and_call_original\n+        result = person.question_sets.new\n+        expect(result).to be_an_instance_of(QuestionSet)\n       end\n \n-      it ':count' do\n-        response = person.question_sets.all(count: 2)\n-        expect(response.count).to eq(2)\n-        assert_requested(api_stub, times: 2)\n+      it \"should save person if not save\" do\n+        person = Person.new","path":"spec/unit/blockscore/question_set_spec.rb","position":null,"original_position":141,"commit_id":"432e09f7baa0130e4d4cceb43fa6ec13783ce320","original_commit_id":"d1e57cb458a828a863cd29a74b3fc2d4aec7e14d","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","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":"Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.","created_at":"2015-09-08T18:51:10Z","updated_at":"2015-09-08T18:51:10Z","html_url":"https://github.com/BlockScore/blockscore-ruby/pull/23#discussion_r38964697","pull_request_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls/comments/38964697"},"html":{"href":"https://github.com/BlockScore/blockscore-ruby/pull/23#discussion_r38964697"},"pull_request":{"href":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls/23","id":43114304,"html_url":"https://github.com/BlockScore/blockscore-ruby/pull/23","diff_url":"https://github.com/BlockScore/blockscore-ruby/pull/23.diff","patch_url":"https://github.com/BlockScore/blockscore-ruby/pull/23.patch","issue_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/issues/23","number":23,"state":"open","locked":false,"title":"Fix/person question sets array","user":{"login":"backus","id":2085622,"avatar_url":"https://avatars.githubusercontent.com/u/2085622?v=3","gravatar_id":"","url":"https://api.github.com/users/backus","html_url":"https://github.com/backus","followers_url":"https://api.github.com/users/backus/followers","following_url":"https://api.github.com/users/backus/following{/other_user}","gists_url":"https://api.github.com/users/backus/gists{/gist_id}","starred_url":"https://api.github.com/users/backus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/backus/subscriptions","organizations_url":"https://api.github.com/users/backus/orgs","repos_url":"https://api.github.com/users/backus/repos","events_url":"https://api.github.com/users/backus/events{/privacy}","received_events_url":"https://api.github.com/users/backus/received_events","type":"User","site_admin":false},"body":"Failing test for issue mentioned in #22.  Good to go @DelmerGA ","created_at":"2015-08-23T02:35:19Z","updated_at":"2015-09-08T18:51:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7ace10e79a75b93a754cae98777dd4ed03d91a86","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls/23/commits","review_comments_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls/23/comments","review_comment_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/issues/23/comments","statuses_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/statuses/432e09f7baa0130e4d4cceb43fa6ec13783ce320","head":{"label":"BlockScore:fix/person-question_sets-array","ref":"fix/person-question_sets-array","sha":"432e09f7baa0130e4d4cceb43fa6ec13783ce320","user":{"login":"BlockScore","id":4524125,"avatar_url":"https://avatars.githubusercontent.com/u/4524125?v=3","gravatar_id":"","url":"https://api.github.com/users/BlockScore","html_url":"https://github.com/BlockScore","followers_url":"https://api.github.com/users/BlockScore/followers","following_url":"https://api.github.com/users/BlockScore/following{/other_user}","gists_url":"https://api.github.com/users/BlockScore/gists{/gist_id}","starred_url":"https://api.github.com/users/BlockScore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BlockScore/subscriptions","organizations_url":"https://api.github.com/users/BlockScore/orgs","repos_url":"https://api.github.com/users/BlockScore/repos","events_url":"https://api.github.com/users/BlockScore/events{/privacy}","received_events_url":"https://api.github.com/users/BlockScore/received_events","type":"Organization","site_admin":false},"repo":{"id":17101801,"name":"blockscore-ruby","full_name":"BlockScore/blockscore-ruby","owner":{"login":"BlockScore","id":4524125,"avatar_url":"https://avatars.githubusercontent.com/u/4524125?v=3","gravatar_id":"","url":"https://api.github.com/users/BlockScore","html_url":"https://github.com/BlockScore","followers_url":"https://api.github.com/users/BlockScore/followers","following_url":"https://api.github.com/users/BlockScore/following{/other_user}","gists_url":"https://api.github.com/users/BlockScore/gists{/gist_id}","starred_url":"https://api.github.com/users/BlockScore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BlockScore/subscriptions","organizations_url":"https://api.github.com/users/BlockScore/orgs","repos_url":"https://api.github.com/users/BlockScore/repos","events_url":"https://api.github.com/users/BlockScore/events{/privacy}","received_events_url":"https://api.github.com/users/BlockScore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BlockScore/blockscore-ruby","description":":gem: An API wrapper for the BlockScore API using Ruby.","fork":false,"url":"https://api.github.com/repos/BlockScore/blockscore-ruby","forks_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/forks","keys_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/teams","hooks_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/hooks","issue_events_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/issues/events{/number}","events_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/events","assignees_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/assignees{/user}","branches_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/branches{/branch}","tags_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/tags","blobs_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/languages","stargazers_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/stargazers","contributors_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/contributors","subscribers_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/subscribers","subscription_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/subscription","commits_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/contents/{+path}","compare_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/merges","archive_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/downloads","issues_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/issues{/number}","pulls_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/labels{/name}","releases_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/releases{/id}","created_at":"2014-02-23T04:46:11Z","updated_at":"2015-08-06T23:27:29Z","pushed_at":"2015-09-08T18:51:06Z","git_url":"git://github.com/BlockScore/blockscore-ruby.git","ssh_url":"git@github.com:BlockScore/blockscore-ruby.git","clone_url":"https://github.com/BlockScore/blockscore-ruby.git","svn_url":"https://github.com/BlockScore/blockscore-ruby","homepage":"http://docs.blockscore.com/ruby/","size":1322,"stargazers_count":6,"watchers_count":6,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":5,"forks":5,"open_issues":5,"watchers":6,"default_branch":"master"}},"base":{"label":"BlockScore:master","ref":"master","sha":"1e428e27fd879e1947a85990fb56788905bed540","user":{"login":"BlockScore","id":4524125,"avatar_url":"https://avatars.githubusercontent.com/u/4524125?v=3","gravatar_id":"","url":"https://api.github.com/users/BlockScore","html_url":"https://github.com/BlockScore","followers_url":"https://api.github.com/users/BlockScore/followers","following_url":"https://api.github.com/users/BlockScore/following{/other_user}","gists_url":"https://api.github.com/users/BlockScore/gists{/gist_id}","starred_url":"https://api.github.com/users/BlockScore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BlockScore/subscriptions","organizations_url":"https://api.github.com/users/BlockScore/orgs","repos_url":"https://api.github.com/users/BlockScore/repos","events_url":"https://api.github.com/users/BlockScore/events{/privacy}","received_events_url":"https://api.github.com/users/BlockScore/received_events","type":"Organization","site_admin":false},"repo":{"id":17101801,"name":"blockscore-ruby","full_name":"BlockScore/blockscore-ruby","owner":{"login":"BlockScore","id":4524125,"avatar_url":"https://avatars.githubusercontent.com/u/4524125?v=3","gravatar_id":"","url":"https://api.github.com/users/BlockScore","html_url":"https://github.com/BlockScore","followers_url":"https://api.github.com/users/BlockScore/followers","following_url":"https://api.github.com/users/BlockScore/following{/other_user}","gists_url":"https://api.github.com/users/BlockScore/gists{/gist_id}","starred_url":"https://api.github.com/users/BlockScore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BlockScore/subscriptions","organizations_url":"https://api.github.com/users/BlockScore/orgs","repos_url":"https://api.github.com/users/BlockScore/repos","events_url":"https://api.github.com/users/BlockScore/events{/privacy}","received_events_url":"https://api.github.com/users/BlockScore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BlockScore/blockscore-ruby","description":":gem: An API wrapper for the BlockScore API using Ruby.","fork":false,"url":"https://api.github.com/repos/BlockScore/blockscore-ruby","forks_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/forks","keys_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/teams","hooks_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/hooks","issue_events_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/issues/events{/number}","events_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/events","assignees_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/assignees{/user}","branches_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/branches{/branch}","tags_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/tags","blobs_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/languages","stargazers_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/stargazers","contributors_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/contributors","subscribers_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/subscribers","subscription_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/subscription","commits_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/contents/{+path}","compare_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/merges","archive_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/downloads","issues_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/issues{/number}","pulls_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/labels{/name}","releases_url":"https://api.github.com/repos/BlockScore/blockscore-ruby/releases{/id}","created_at":"2014-02-23T04:46:11Z","updated_at":"2015-08-06T23:27:29Z","pushed_at":"2015-09-08T18:51:06Z","git_url":"git://github.com/BlockScore/blockscore-ruby.git","ssh_url":"git@github.com:BlockScore/blockscore-ruby.git","clone_url":"https://github.com/BlockScore/blockscore-ruby.git","svn_url":"https://github.com/BlockScore/blockscore-ruby","homepage":"http://docs.blockscore.com/ruby/","size":1322,"stargazers_count":6,"watchers_count":6,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":5,"forks":5,"open_issues":5,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls/23"},"html":{"href":"https://github.com/BlockScore/blockscore-ruby/pull/23"},"issue":{"href":"https://api.github.com/repos/BlockScore/blockscore-ruby/issues/23"},"comments":{"href":"https://api.github.com/repos/BlockScore/blockscore-ruby/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BlockScore/blockscore-ruby/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/BlockScore/blockscore-ruby/statuses/432e09f7baa0130e4d4cceb43fa6ec13783ce320"}}}}