{"action":"created","comment":{"url":"https://api.github.com/repos/filipemir/argot/pulls/comments/60674456","id":60674456,"diff_hunk":"@@ -1,35 +1,98 @@\n require 'rails_helper'\n \n RSpec.describe Artist do\n-  before :each do\n-    artist = FactoryGirl.create(:artist, name: 'Aesop Rock')\n+\n+  let(:artist) { FactoryGirl.create(:artist, name: 'Tom Waits') }\n+\n+  describe '#discogs_id' do\n+    it \"returns artist's discogs id\" do\n+      expect(artist.discogs_id).to eq(82294)\n+    end\n+\n+    it \"updates artist's discogs id\" do\n+      expect(artist.read_attribute(:discogs_id)).to be_nil\n+      artist.discogs_id\n+      expect(artist.read_attribute(:discogs_id)).to eq(82294)\n+    end\n   end\n \n-  describe '#name' do\n-    it \"returns artist's names\" do\n-      expect(artist.name).to eq('Aesop Rock')\n+  describe '#total_words' do\n+    it 'returns zero if no lyrics are stored in db' do\n+      expect(artist.total_words).to eq(0)\n+    end\n+\n+    it 'returns total number of words in lyrics stored in db' do\n+      artist.update\n+      expect(artist.total_words).to be_a Integer\n+      expect(artist.total_words).to be > WORD_SAMPLE_SIZE\n     end\n   end\n \n-  describe '#id' do\n-    it \"returns artist's lastfm id\" do\n-      expect(artist.id).to eq(666)\n+  describe '#update_records' do\n+    it \"updates records if records weren't previously loaded\" do\n+      expect { artist.update_records }.to output.to_stdout\n+      expect(artist.records).to_not be([])\n+      expect(artist.records.sample).to be_a Record\n+    end\n+\n+    it \"leaves records unchanged if records already in db\" do\n+      artist.update_records\n+      expect { artist.update_records }.to_not output.to_stdout\n+      expect(artist.records).to_not be([])\n+      expect(artist.records.sample).to be_a Record\n     end\n   end\n \n-  describe '#records' do\n-    it \"returns array with artist's records\" do\n-      expect(artist.records).to be_a Array\n-      expect(artist.records.length).to eq(1)\n+  describe '#update' do\n+    it \"updates artist's discogs id\" do\n+      expect(artist.read_attribute(:discogs_id)).to be_nil\n+      artist.update\n+      expect(artist.read_attribute(:discogs_id)).to eq(82294)\n+    end\n+\n+    it \"updates records if records weren't previously loaded\" do\n+      expect { artist.update }.to output.to_stdout\n+      expect(artist.records).to_not be([])\n+      expect(artist.records.sample).to be_a Record\n+    end\n+\n+    it \"leaves records unchanged if records already in db\" do\n+      artist.update\n+      expect { artist.update }.to_not output.to_stdout\n+      expect(artist.records).to_not be([])\n       expect(artist.records.sample).to be_a Record\n     end\n   end\n \n-  describe '#songs' do\n-    it \"returns array with artist's songs\" do\n-      expect(artist.records).to be_a Array\n-      expect(artist.records.length).to eq(1)\n-      expect(artist.records.sample).to be_a Song\n+  describe '#songs_sorted' do\n+    before { artist.update }\n+\n+    it \"returns artist's songs\" do\n+      expect(artist.songs_sorted.length).to eq(artist.songs.length)\n+      expect(artist.songs_sorted.sample).to be_a Song\n+    end\n+\n+    it \"returns songs sorted by release year in ascending order\" do\n+      songs = artist.songs_sorted\n+      (1..songs.length-1).each do |i|\n+        expect(songs[i - 1].record.year).to be <= songs[i].record.year\n+      end\n+    end\n+\n+    it \"sorts songs by record title within the same year\" do\n+      songs = artist.songs_sorted.select { |song| song.record.year == 1973 }\n+      (1..songs.length-1).each do |i|","path":"spec/models/artist_spec.rb","position":101,"original_position":101,"commit_id":"c1eb1c3fedb7ad1cefbac1abc732845f17b13b0d","original_commit_id":"c1eb1c3fedb7ad1cefbac1abc732845f17b13b0d","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":"Surrounding space missing for operator `-`.","created_at":"2016-04-22T00:08:22Z","updated_at":"2016-04-22T00:08:22Z","html_url":"https://github.com/filipemir/argot/pull/7#discussion_r60674456","pull_request_url":"https://api.github.com/repos/filipemir/argot/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/filipemir/argot/pulls/comments/60674456"},"html":{"href":"https://github.com/filipemir/argot/pull/7#discussion_r60674456"},"pull_request":{"href":"https://api.github.com/repos/filipemir/argot/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/filipemir/argot/pulls/7","id":67422153,"html_url":"https://github.com/filipemir/argot/pull/7","diff_url":"https://github.com/filipemir/argot/pull/7.diff","patch_url":"https://github.com/filipemir/argot/pull/7.patch","issue_url":"https://api.github.com/repos/filipemir/argot/issues/7","number":7,"state":"open","locked":false,"title":"Model tests","user":{"login":"filipemir","id":13949291,"avatar_url":"https://avatars.githubusercontent.com/u/13949291?v=3","gravatar_id":"","url":"https://api.github.com/users/filipemir","html_url":"https://github.com/filipemir","followers_url":"https://api.github.com/users/filipemir/followers","following_url":"https://api.github.com/users/filipemir/following{/other_user}","gists_url":"https://api.github.com/users/filipemir/gists{/gist_id}","starred_url":"https://api.github.com/users/filipemir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filipemir/subscriptions","organizations_url":"https://api.github.com/users/filipemir/orgs","repos_url":"https://api.github.com/users/filipemir/repos","events_url":"https://api.github.com/users/filipemir/events{/privacy}","received_events_url":"https://api.github.com/users/filipemir/received_events","type":"User","site_admin":false},"body":"Added tests for user, artist, record, and song modes. Cleared tests.","created_at":"2016-04-21T21:04:23Z","updated_at":"2016-04-22T00:08:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ef2c3b6c1634032a91cd793bed3c77f2dc6f0f10","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/filipemir/argot/pulls/7/commits","review_comments_url":"https://api.github.com/repos/filipemir/argot/pulls/7/comments","review_comment_url":"https://api.github.com/repos/filipemir/argot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/filipemir/argot/issues/7/comments","statuses_url":"https://api.github.com/repos/filipemir/argot/statuses/c1eb1c3fedb7ad1cefbac1abc732845f17b13b0d","head":{"label":"filipemir:model_tests","ref":"model_tests","sha":"c1eb1c3fedb7ad1cefbac1abc732845f17b13b0d","user":{"login":"filipemir","id":13949291,"avatar_url":"https://avatars.githubusercontent.com/u/13949291?v=3","gravatar_id":"","url":"https://api.github.com/users/filipemir","html_url":"https://github.com/filipemir","followers_url":"https://api.github.com/users/filipemir/followers","following_url":"https://api.github.com/users/filipemir/following{/other_user}","gists_url":"https://api.github.com/users/filipemir/gists{/gist_id}","starred_url":"https://api.github.com/users/filipemir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filipemir/subscriptions","organizations_url":"https://api.github.com/users/filipemir/orgs","repos_url":"https://api.github.com/users/filipemir/repos","events_url":"https://api.github.com/users/filipemir/events{/privacy}","received_events_url":"https://api.github.com/users/filipemir/received_events","type":"User","site_admin":false},"repo":{"id":55411631,"name":"argot","full_name":"filipemir/argot","owner":{"login":"filipemir","id":13949291,"avatar_url":"https://avatars.githubusercontent.com/u/13949291?v=3","gravatar_id":"","url":"https://api.github.com/users/filipemir","html_url":"https://github.com/filipemir","followers_url":"https://api.github.com/users/filipemir/followers","following_url":"https://api.github.com/users/filipemir/following{/other_user}","gists_url":"https://api.github.com/users/filipemir/gists{/gist_id}","starred_url":"https://api.github.com/users/filipemir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filipemir/subscriptions","organizations_url":"https://api.github.com/users/filipemir/orgs","repos_url":"https://api.github.com/users/filipemir/repos","events_url":"https://api.github.com/users/filipemir/events{/privacy}","received_events_url":"https://api.github.com/users/filipemir/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/filipemir/argot","description":"","fork":false,"url":"https://api.github.com/repos/filipemir/argot","forks_url":"https://api.github.com/repos/filipemir/argot/forks","keys_url":"https://api.github.com/repos/filipemir/argot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/filipemir/argot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/filipemir/argot/teams","hooks_url":"https://api.github.com/repos/filipemir/argot/hooks","issue_events_url":"https://api.github.com/repos/filipemir/argot/issues/events{/number}","events_url":"https://api.github.com/repos/filipemir/argot/events","assignees_url":"https://api.github.com/repos/filipemir/argot/assignees{/user}","branches_url":"https://api.github.com/repos/filipemir/argot/branches{/branch}","tags_url":"https://api.github.com/repos/filipemir/argot/tags","blobs_url":"https://api.github.com/repos/filipemir/argot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/filipemir/argot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/filipemir/argot/git/refs{/sha}","trees_url":"https://api.github.com/repos/filipemir/argot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/filipemir/argot/statuses/{sha}","languages_url":"https://api.github.com/repos/filipemir/argot/languages","stargazers_url":"https://api.github.com/repos/filipemir/argot/stargazers","contributors_url":"https://api.github.com/repos/filipemir/argot/contributors","subscribers_url":"https://api.github.com/repos/filipemir/argot/subscribers","subscription_url":"https://api.github.com/repos/filipemir/argot/subscription","commits_url":"https://api.github.com/repos/filipemir/argot/commits{/sha}","git_commits_url":"https://api.github.com/repos/filipemir/argot/git/commits{/sha}","comments_url":"https://api.github.com/repos/filipemir/argot/comments{/number}","issue_comment_url":"https://api.github.com/repos/filipemir/argot/issues/comments{/number}","contents_url":"https://api.github.com/repos/filipemir/argot/contents/{+path}","compare_url":"https://api.github.com/repos/filipemir/argot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/filipemir/argot/merges","archive_url":"https://api.github.com/repos/filipemir/argot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/filipemir/argot/downloads","issues_url":"https://api.github.com/repos/filipemir/argot/issues{/number}","pulls_url":"https://api.github.com/repos/filipemir/argot/pulls{/number}","milestones_url":"https://api.github.com/repos/filipemir/argot/milestones{/number}","notifications_url":"https://api.github.com/repos/filipemir/argot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/filipemir/argot/labels{/name}","releases_url":"https://api.github.com/repos/filipemir/argot/releases{/id}","deployments_url":"https://api.github.com/repos/filipemir/argot/deployments","created_at":"2016-04-04T13:04:10Z","updated_at":"2016-04-19T15:43:33Z","pushed_at":"2016-04-22T00:08:14Z","git_url":"git://github.com/filipemir/argot.git","ssh_url":"git@github.com:filipemir/argot.git","clone_url":"https://github.com/filipemir/argot.git","svn_url":"https://github.com/filipemir/argot","homepage":null,"size":213,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"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":"filipemir:master","ref":"master","sha":"2196d4a187f86b775cb27ca3bf0e0741781f9953","user":{"login":"filipemir","id":13949291,"avatar_url":"https://avatars.githubusercontent.com/u/13949291?v=3","gravatar_id":"","url":"https://api.github.com/users/filipemir","html_url":"https://github.com/filipemir","followers_url":"https://api.github.com/users/filipemir/followers","following_url":"https://api.github.com/users/filipemir/following{/other_user}","gists_url":"https://api.github.com/users/filipemir/gists{/gist_id}","starred_url":"https://api.github.com/users/filipemir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filipemir/subscriptions","organizations_url":"https://api.github.com/users/filipemir/orgs","repos_url":"https://api.github.com/users/filipemir/repos","events_url":"https://api.github.com/users/filipemir/events{/privacy}","received_events_url":"https://api.github.com/users/filipemir/received_events","type":"User","site_admin":false},"repo":{"id":55411631,"name":"argot","full_name":"filipemir/argot","owner":{"login":"filipemir","id":13949291,"avatar_url":"https://avatars.githubusercontent.com/u/13949291?v=3","gravatar_id":"","url":"https://api.github.com/users/filipemir","html_url":"https://github.com/filipemir","followers_url":"https://api.github.com/users/filipemir/followers","following_url":"https://api.github.com/users/filipemir/following{/other_user}","gists_url":"https://api.github.com/users/filipemir/gists{/gist_id}","starred_url":"https://api.github.com/users/filipemir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filipemir/subscriptions","organizations_url":"https://api.github.com/users/filipemir/orgs","repos_url":"https://api.github.com/users/filipemir/repos","events_url":"https://api.github.com/users/filipemir/events{/privacy}","received_events_url":"https://api.github.com/users/filipemir/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/filipemir/argot","description":"","fork":false,"url":"https://api.github.com/repos/filipemir/argot","forks_url":"https://api.github.com/repos/filipemir/argot/forks","keys_url":"https://api.github.com/repos/filipemir/argot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/filipemir/argot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/filipemir/argot/teams","hooks_url":"https://api.github.com/repos/filipemir/argot/hooks","issue_events_url":"https://api.github.com/repos/filipemir/argot/issues/events{/number}","events_url":"https://api.github.com/repos/filipemir/argot/events","assignees_url":"https://api.github.com/repos/filipemir/argot/assignees{/user}","branches_url":"https://api.github.com/repos/filipemir/argot/branches{/branch}","tags_url":"https://api.github.com/repos/filipemir/argot/tags","blobs_url":"https://api.github.com/repos/filipemir/argot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/filipemir/argot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/filipemir/argot/git/refs{/sha}","trees_url":"https://api.github.com/repos/filipemir/argot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/filipemir/argot/statuses/{sha}","languages_url":"https://api.github.com/repos/filipemir/argot/languages","stargazers_url":"https://api.github.com/repos/filipemir/argot/stargazers","contributors_url":"https://api.github.com/repos/filipemir/argot/contributors","subscribers_url":"https://api.github.com/repos/filipemir/argot/subscribers","subscription_url":"https://api.github.com/repos/filipemir/argot/subscription","commits_url":"https://api.github.com/repos/filipemir/argot/commits{/sha}","git_commits_url":"https://api.github.com/repos/filipemir/argot/git/commits{/sha}","comments_url":"https://api.github.com/repos/filipemir/argot/comments{/number}","issue_comment_url":"https://api.github.com/repos/filipemir/argot/issues/comments{/number}","contents_url":"https://api.github.com/repos/filipemir/argot/contents/{+path}","compare_url":"https://api.github.com/repos/filipemir/argot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/filipemir/argot/merges","archive_url":"https://api.github.com/repos/filipemir/argot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/filipemir/argot/downloads","issues_url":"https://api.github.com/repos/filipemir/argot/issues{/number}","pulls_url":"https://api.github.com/repos/filipemir/argot/pulls{/number}","milestones_url":"https://api.github.com/repos/filipemir/argot/milestones{/number}","notifications_url":"https://api.github.com/repos/filipemir/argot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/filipemir/argot/labels{/name}","releases_url":"https://api.github.com/repos/filipemir/argot/releases{/id}","deployments_url":"https://api.github.com/repos/filipemir/argot/deployments","created_at":"2016-04-04T13:04:10Z","updated_at":"2016-04-19T15:43:33Z","pushed_at":"2016-04-22T00:08:14Z","git_url":"git://github.com/filipemir/argot.git","ssh_url":"git@github.com:filipemir/argot.git","clone_url":"https://github.com/filipemir/argot.git","svn_url":"https://github.com/filipemir/argot","homepage":null,"size":213,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"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/filipemir/argot/pulls/7"},"html":{"href":"https://github.com/filipemir/argot/pull/7"},"issue":{"href":"https://api.github.com/repos/filipemir/argot/issues/7"},"comments":{"href":"https://api.github.com/repos/filipemir/argot/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/filipemir/argot/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/filipemir/argot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/filipemir/argot/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/filipemir/argot/statuses/c1eb1c3fedb7ad1cefbac1abc732845f17b13b0d"}}}}