GitHub PullRequestReviewCommentEvent at 2014-12-18 08:43:05
Repository: twimock
Actor: ogawatti
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/ogawatti/twimock/pulls/comments/22028895","id":22028895,"diff_hunk":"@@ -1,112 +1,125 @@\n require 'spec_helper'\n require 'tempfile'\n+require 'faker'\n \n describe Twimock::Config do\n   let(:db_name) { \".test\" }\n-  let(:ymlfile) { \"testdata.yml\" }\n-\n+  let(:database) { Twimock::Database.new }\n   before { stub_const(\"Twimock::Database::DEFAULT_DB_NAME\", db_name) }\n+  after { database.drop }\n \n-  describe '#default_database' do\n-    before do\n-      allow_any_instance_of(Twimock::Database).to receive(:connect) { true }\n-      allow_any_instance_of(Twimock::Database).to receive(:create_tables) { true }\n-      allow_any_instance_of(Twimock::Database).to receive(:disconnect!) { true }\n-    end\n-\n-    subject { Twimock::Config.default_database }\n-    it { is_expected.to be_truthy }\n-\n-    describe '.name' do\n-      subject { Twimock::Config.default_database.name }\n-      it { is_expected.not_to be_nil }\n-      it { is_expected.not_to be_empty }\n-    end\n-  end\n-\n-  describe '#database' do\n-    before do\n-      allow_any_instance_of(Twimock::Database).to receive(:connect) { true }\n-      allow_any_instance_of(Twimock::Database).to receive(:create_tables) { true }\n-      allow_any_instance_of(Twimock::Database).to receive(:disconnect!) { true }\n-    end\n+  ['default_database', 'database']. each do |db|\n+    describe \"##{db}\" do\n+      before do\n+        [:connect, :create_tables, :disconnect!].each do |method|\n+          allow_any_instance_of(Twimock::Database).to receive(method) { true }\n+        end\n+      end\n \n-    subject { Twimock::Config.database }\n-    it { is_expected.to be_truthy }\n+      subject { Twimock::Config.send(db) }\n+      it { is_expected.to be_truthy }\n \n-    describe '.name' do\n-      subject { Twimock::Config.database.name }\n-      it { is_expected.not_to be_nil }\n-      it { is_expected.not_to be_empty }\n+      describe '.name' do\n+        subject { Twimock::Config.send(db).name }\n+        it { is_expected.not_to be_nil }\n+        it { is_expected.not_to be_empty }\n+      end\n     end\n   end\n \n   describe '#reset_database' do\n-    context 'when does not set database' do\n-      subject { Twimock::Config.reset_database }\n-      it { is_expected.to eq nil }\n-    end\n-\n-    context 'when already set database' do\n-      before do\n-        stub_const(\"Twimock::Database::DEFAULT_DATABASE_NAME\", db_name)\n-        @database = Twimock::Database.new\n-      end\n-\n-      subject { Twimock::Config.reset_database }\n-      it { is_expected.to eq nil }\n-\n-      after { @database.drop }\n-    end\n+    subject { Twimock::Config.reset_database }\n+    it { is_expected.to be_nil }\n   end\n \n   describe '#load_users' do\n+    let(:app) { app_data }\n+    let(:yaml_load_data) { [app] }\n+    let(:path) { create_temporary_yaml_file(yaml_load_data) }\n+\n     context 'without argument' do\n       subject { lambda { Twimock::Config.load_users } }\n       it { is_expected.to raise_error ArgumentError }\n     end\n \n     context 'with yaml file path' do\n-      before do\n-        stub_const(\"Twimock::Database::DEFAULT_DB_NAME\", db_name)\n-        @database = Twimock::Database.new\n-      end\n-      after  { @database.drop }\n+      subject { lambda { Twimock::Config.load_users(path) } }\n \n       context 'but file does not exist' do\n-        subject { lambda { Twimock::Config.load_users(\"testdata.yml\") } }\n+        let(:path) { 'testdata.yml' }\n         it { is_expected.to raise_error Errno::ENOENT }\n       end\n \n-      def create_temporary_yaml_file(data)\n-        path = Tempfile.open(ymlfile) do |tempfile|\n-          tempfile.puts YAML.dump(data)\n-          tempfile.path\n-        end\n-      end\n-\n       shared_context 'app and user should not be created', assert: :incorrect_data_format do\n-        subject { lambda { Twimock::Config.load_users(@path) } }\n-        it { is_expected.to raise_error Twimock::Errors::IncorrectDataFormat }\n-\n         it 'app and user should not be created' do\n-          begin\n-            Twimock::Config.load_users(@path)\n-          rescue => error\n-            expect(Twimock::Application.all).to be_empty\n-            expect(Twimock::User.all).to be_empty\n-          end\n+          is_expected.to raise_error Twimock::Errors::IncorrectDataFormat\n+          expect(Twimock::Application.all).to be_empty\n+          expect(Twimock::User.all).to be_empty\n         end\n       end\n \n       context 'but incorrect format' do\n         context 'when load data is not array', assert: :incorrect_data_format do\n-          before do\n-            users_data = \"\"\n-            @path = create_temporary_yaml_file(users_data)\n+          let(:yaml_load_data) { \"\" }\n+        end\n+\n+        [:id, :api_key, :api_secret, :users].each do |key|\n+          context \"when #{key} is not exist\", assert: :incorrect_data_format do\n+            before { app.delete(key) }\n           end\n         end\n+\n+        [:id, :name, :password, :access_token, :access_token_secret, :application_id].each do |key|\n+          context \"when users #{key} is not exist\", assert: :incorrect_data_format do\n+            before { app[:users].first.delete(key) }\n+          end\n+        end\n+      end\n+\n+      context 'yaml is correct format' do\n+        let(:yaml_load_data) { [app_data, app_data(2)] }\n+        let(:app_count) { yaml_load_data.size }\n+        let(:user_count) { yaml_load_data.inject(0){ |count, data| count += data[:users].size } }\n+\n+        it 'app and user should be created' do","path":"spec/twimock/config_spec.rb","position":156,"original_position":156,"commit_id":"aebef31cbc467f7563c2850b9841c6fa1e0d5761","original_commit_id":"aebef31cbc467f7563c2850b9841c6fa1e0d5761","user":{"login":"ogawatti","id":2460254,"avatar_url":"https://avatars.githubusercontent.com/u/2460254?v=3","gravatar_id":"","url":"https://api.github.com/users/ogawatti","html_url":"https://github.com/ogawatti","followers_url":"https://api.github.com/users/ogawatti/followers","following_url":"https://api.github.com/users/ogawatti/following{/other_user}","gists_url":"https://api.github.com/users/ogawatti/gists{/gist_id}","starred_url":"https://api.github.com/users/ogawatti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ogawatti/subscriptions","organizations_url":"https://api.github.com/users/ogawatti/orgs","repos_url":"https://api.github.com/users/ogawatti/repos","events_url":"https://api.github.com/users/ogawatti/events{/privacy}","received_events_url":"https://api.github.com/users/ogawatti/received_events","type":"User","site_admin":false},"body":"前述の\r\n* https://github.com/ogawatti/twimock/pull/1/files#r21880972\r\n\r\nと関連しますが、yamlの中身とDBに挿入したデータとの整合性の確認が不十分です。\r\n今は「yamlに書いたデータ数とアップ数・ユーザ数が一致すること」しか言えてないです。\r\n**DBに挿入されたデータが正しいこと**のテストを追加してください。","created_at":"2014-12-18T08:43:05Z","updated_at":"2014-12-18T08:43:05Z","html_url":"https://github.com/ogawatti/twimock/pull/1#discussion_r22028895","pull_request_url":"https://api.github.com/repos/ogawatti/twimock/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/ogawatti/twimock/pulls/comments/22028895"},"html":{"href":"https://github.com/ogawatti/twimock/pull/1#discussion_r22028895"},"pull_request":{"href":"https://api.github.com/repos/ogawatti/twimock/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/ogawatti/twimock/pulls/1","id":26125623,"html_url":"https://github.com/ogawatti/twimock/pull/1","diff_url":"https://github.com/ogawatti/twimock/pull/1.diff","patch_url":"https://github.com/ogawatti/twimock/pull/1.patch","issue_url":"https://api.github.com/repos/ogawatti/twimock/issues/1","number":1,"state":"open","locked":false,"title":"Feature/tm 1","user":{"login":"RustyNail","id":821981,"avatar_url":"https://avatars.githubusercontent.com/u/821981?v=3","gravatar_id":"","url":"https://api.github.com/users/RustyNail","html_url":"https://github.com/RustyNail","followers_url":"https://api.github.com/users/RustyNail/followers","following_url":"https://api.github.com/users/RustyNail/following{/other_user}","gists_url":"https://api.github.com/users/RustyNail/gists{/gist_id}","starred_url":"https://api.github.com/users/RustyNail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RustyNail/subscriptions","organizations_url":"https://api.github.com/users/RustyNail/orgs","repos_url":"https://api.github.com/users/RustyNail/repos","events_url":"https://api.github.com/users/RustyNail/events{/privacy}","received_events_url":"https://api.github.com/users/RustyNail/received_events","type":"User","site_admin":false},"body":"load_usersを実装しました\r\n既存のテストコードも少しリファクタリングを","created_at":"2014-12-16T06:28:55Z","updated_at":"2014-12-18T08:43:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b20a2e77c0f37f44dabedba56899f79fd86031b3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ogawatti/twimock/pulls/1/commits","review_comments_url":"https://api.github.com/repos/ogawatti/twimock/pulls/1/comments","review_comment_url":"https://api.github.com/repos/ogawatti/twimock/pulls/comments/{number}","comments_url":"https://api.github.com/repos/ogawatti/twimock/issues/1/comments","statuses_url":"https://api.github.com/repos/ogawatti/twimock/statuses/aebef31cbc467f7563c2850b9841c6fa1e0d5761","head":{"label":"RustyNail:feature/TM-1","ref":"feature/TM-1","sha":"aebef31cbc467f7563c2850b9841c6fa1e0d5761","user":{"login":"RustyNail","id":821981,"avatar_url":"https://avatars.githubusercontent.com/u/821981?v=3","gravatar_id":"","url":"https://api.github.com/users/RustyNail","html_url":"https://github.com/RustyNail","followers_url":"https://api.github.com/users/RustyNail/followers","following_url":"https://api.github.com/users/RustyNail/following{/other_user}","gists_url":"https://api.github.com/users/RustyNail/gists{/gist_id}","starred_url":"https://api.github.com/users/RustyNail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RustyNail/subscriptions","organizations_url":"https://api.github.com/users/RustyNail/orgs","repos_url":"https://api.github.com/users/RustyNail/repos","events_url":"https://api.github.com/users/RustyNail/events{/privacy}","received_events_url":"https://api.github.com/users/RustyNail/received_events","type":"User","site_admin":false},"repo":{"id":27357600,"name":"twimock","full_name":"RustyNail/twimock","owner":{"login":"RustyNail","id":821981,"avatar_url":"https://avatars.githubusercontent.com/u/821981?v=3","gravatar_id":"","url":"https://api.github.com/users/RustyNail","html_url":"https://github.com/RustyNail","followers_url":"https://api.github.com/users/RustyNail/followers","following_url":"https://api.github.com/users/RustyNail/following{/other_user}","gists_url":"https://api.github.com/users/RustyNail/gists{/gist_id}","starred_url":"https://api.github.com/users/RustyNail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RustyNail/subscriptions","organizations_url":"https://api.github.com/users/RustyNail/orgs","repos_url":"https://api.github.com/users/RustyNail/repos","events_url":"https://api.github.com/users/RustyNail/events{/privacy}","received_events_url":"https://api.github.com/users/RustyNail/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RustyNail/twimock","description":"This is twitter mock library.","fork":true,"url":"https://api.github.com/repos/RustyNail/twimock","forks_url":"https://api.github.com/repos/RustyNail/twimock/forks","keys_url":"https://api.github.com/repos/RustyNail/twimock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RustyNail/twimock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RustyNail/twimock/teams","hooks_url":"https://api.github.com/repos/RustyNail/twimock/hooks","issue_events_url":"https://api.github.com/repos/RustyNail/twimock/issues/events{/number}","events_url":"https://api.github.com/repos/RustyNail/twimock/events","assignees_url":"https://api.github.com/repos/RustyNail/twimock/assignees{/user}","branches_url":"https://api.github.com/repos/RustyNail/twimock/branches{/branch}","tags_url":"https://api.github.com/repos/RustyNail/twimock/tags","blobs_url":"https://api.github.com/repos/RustyNail/twimock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RustyNail/twimock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RustyNail/twimock/git/refs{/sha}","trees_url":"https://api.github.com/repos/RustyNail/twimock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RustyNail/twimock/statuses/{sha}","languages_url":"https://api.github.com/repos/RustyNail/twimock/languages","stargazers_url":"https://api.github.com/repos/RustyNail/twimock/stargazers","contributors_url":"https://api.github.com/repos/RustyNail/twimock/contributors","subscribers_url":"https://api.github.com/repos/RustyNail/twimock/subscribers","subscription_url":"https://api.github.com/repos/RustyNail/twimock/subscription","commits_url":"https://api.github.com/repos/RustyNail/twimock/commits{/sha}","git_commits_url":"https://api.github.com/repos/RustyNail/twimock/git/commits{/sha}","comments_url":"https://api.github.com/repos/RustyNail/twimock/comments{/number}","issue_comment_url":"https://api.github.com/repos/RustyNail/twimock/issues/comments/{number}","contents_url":"https://api.github.com/repos/RustyNail/twimock/contents/{+path}","compare_url":"https://api.github.com/repos/RustyNail/twimock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RustyNail/twimock/merges","archive_url":"https://api.github.com/repos/RustyNail/twimock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RustyNail/twimock/downloads","issues_url":"https://api.github.com/repos/RustyNail/twimock/issues{/number}","pulls_url":"https://api.github.com/repos/RustyNail/twimock/pulls{/number}","milestones_url":"https://api.github.com/repos/RustyNail/twimock/milestones{/number}","notifications_url":"https://api.github.com/repos/RustyNail/twimock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RustyNail/twimock/labels{/name}","releases_url":"https://api.github.com/repos/RustyNail/twimock/releases{/id}","created_at":"2014-12-01T01:42:12Z","updated_at":"2014-12-01T01:42:12Z","pushed_at":"2014-12-18T07:58:52Z","git_url":"git://github.com/RustyNail/twimock.git","ssh_url":"git@github.com:RustyNail/twimock.git","clone_url":"https://github.com/RustyNail/twimock.git","svn_url":"https://github.com/RustyNail/twimock","homepage":"","size":142,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"ogawatti:develop","ref":"develop","sha":"80b438d4f182ce368672cae19ca3c3060292f8ae","user":{"login":"ogawatti","id":2460254,"avatar_url":"https://avatars.githubusercontent.com/u/2460254?v=3","gravatar_id":"","url":"https://api.github.com/users/ogawatti","html_url":"https://github.com/ogawatti","followers_url":"https://api.github.com/users/ogawatti/followers","following_url":"https://api.github.com/users/ogawatti/following{/other_user}","gists_url":"https://api.github.com/users/ogawatti/gists{/gist_id}","starred_url":"https://api.github.com/users/ogawatti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ogawatti/subscriptions","organizations_url":"https://api.github.com/users/ogawatti/orgs","repos_url":"https://api.github.com/users/ogawatti/repos","events_url":"https://api.github.com/users/ogawatti/events{/privacy}","received_events_url":"https://api.github.com/users/ogawatti/received_events","type":"User","site_admin":false},"repo":{"id":25859923,"name":"twimock","full_name":"ogawatti/twimock","owner":{"login":"ogawatti","id":2460254,"avatar_url":"https://avatars.githubusercontent.com/u/2460254?v=3","gravatar_id":"","url":"https://api.github.com/users/ogawatti","html_url":"https://github.com/ogawatti","followers_url":"https://api.github.com/users/ogawatti/followers","following_url":"https://api.github.com/users/ogawatti/following{/other_user}","gists_url":"https://api.github.com/users/ogawatti/gists{/gist_id}","starred_url":"https://api.github.com/users/ogawatti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ogawatti/subscriptions","organizations_url":"https://api.github.com/users/ogawatti/orgs","repos_url":"https://api.github.com/users/ogawatti/repos","events_url":"https://api.github.com/users/ogawatti/events{/privacy}","received_events_url":"https://api.github.com/users/ogawatti/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ogawatti/twimock","description":"This is twitter mock library.","fork":false,"url":"https://api.github.com/repos/ogawatti/twimock","forks_url":"https://api.github.com/repos/ogawatti/twimock/forks","keys_url":"https://api.github.com/repos/ogawatti/twimock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ogawatti/twimock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ogawatti/twimock/teams","hooks_url":"https://api.github.com/repos/ogawatti/twimock/hooks","issue_events_url":"https://api.github.com/repos/ogawatti/twimock/issues/events{/number}","events_url":"https://api.github.com/repos/ogawatti/twimock/events","assignees_url":"https://api.github.com/repos/ogawatti/twimock/assignees{/user}","branches_url":"https://api.github.com/repos/ogawatti/twimock/branches{/branch}","tags_url":"https://api.github.com/repos/ogawatti/twimock/tags","blobs_url":"https://api.github.com/repos/ogawatti/twimock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ogawatti/twimock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ogawatti/twimock/git/refs{/sha}","trees_url":"https://api.github.com/repos/ogawatti/twimock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ogawatti/twimock/statuses/{sha}","languages_url":"https://api.github.com/repos/ogawatti/twimock/languages","stargazers_url":"https://api.github.com/repos/ogawatti/twimock/stargazers","contributors_url":"https://api.github.com/repos/ogawatti/twimock/contributors","subscribers_url":"https://api.github.com/repos/ogawatti/twimock/subscribers","subscription_url":"https://api.github.com/repos/ogawatti/twimock/subscription","commits_url":"https://api.github.com/repos/ogawatti/twimock/commits{/sha}","git_commits_url":"https://api.github.com/repos/ogawatti/twimock/git/commits{/sha}","comments_url":"https://api.github.com/repos/ogawatti/twimock/comments{/number}","issue_comment_url":"https://api.github.com/repos/ogawatti/twimock/issues/comments/{number}","contents_url":"https://api.github.com/repos/ogawatti/twimock/contents/{+path}","compare_url":"https://api.github.com/repos/ogawatti/twimock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ogawatti/twimock/merges","archive_url":"https://api.github.com/repos/ogawatti/twimock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ogawatti/twimock/downloads","issues_url":"https://api.github.com/repos/ogawatti/twimock/issues{/number}","pulls_url":"https://api.github.com/repos/ogawatti/twimock/pulls{/number}","milestones_url":"https://api.github.com/repos/ogawatti/twimock/milestones{/number}","notifications_url":"https://api.github.com/repos/ogawatti/twimock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ogawatti/twimock/labels{/name}","releases_url":"https://api.github.com/repos/ogawatti/twimock/releases{/id}","created_at":"2014-10-28T08:33:55Z","updated_at":"2014-10-29T00:04:21Z","pushed_at":"2014-10-30T03:05:40Z","git_url":"git://github.com/ogawatti/twimock.git","ssh_url":"git@github.com:ogawatti/twimock.git","clone_url":"https://github.com/ogawatti/twimock.git","svn_url":"https://github.com/ogawatti/twimock","homepage":"","size":156,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ogawatti/twimock/pulls/1"},"html":{"href":"https://github.com/ogawatti/twimock/pull/1"},"issue":{"href":"https://api.github.com/repos/ogawatti/twimock/issues/1"},"comments":{"href":"https://api.github.com/repos/ogawatti/twimock/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/ogawatti/twimock/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/ogawatti/twimock/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/ogawatti/twimock/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/ogawatti/twimock/statuses/aebef31cbc467f7563c2850b9841c6fa1e0d5761"}}}}