{"action":"created","comment":{"url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls/comments/75073351","id":75073351,"diff_hunk":"@@ -0,0 +1,33 @@\n+require 'rails_helper'\n+\n+describe AnswersController do\n+  let(:question) { create :question }\n+  let(:valid_attr) { { body: 'My answer' } }\n+  let(:invalid_attr) { { body: nil } }\n+  describe 'POST #create' do\n+    context 'with valid attributes' do\n+      it 'save answer to the question in database' do\n+        expect { post :create, params: { answer: valid_attr, question_id: question } }\n+          .to change(question.answers, :count).by(1)\n+      end\n+\n+      it 'redirect to question view' do\n+        post :create, params: { answer: valid_attr, question_id: question }\n+        expect(response).to redirect_to question_path(id: question)\n+      end\n+    end\n+\n+    context 'with invalid attributes' do\n+      it 'not save answer' do\n+        expect { post :create, params: { answer: invalid_attr, question_id: question } }\n+          .to_not change(question.answers, :count)\n+      end\n+\n+      it 'redirect to question view with errors message' do\n+        post :create, params: { answer: invalid_attr, question_id: question }\n+        expect(response).to redirect_to question_path(id: question)\n+        expect(flash[:warning]).to be_present","path":"spec/controllers/answers_controller_spec.rb","position":29,"original_position":29,"commit_id":"fd248e4075894da89a1a1eba2dd7470a11c5be85","original_commit_id":"fd248e4075894da89a1a1eba2dd7470a11c5be85","user":{"login":"palkan","id":1516722,"avatar_url":"https://avatars.githubusercontent.com/u/1516722?v=3","gravatar_id":"","url":"https://api.github.com/users/palkan","html_url":"https://github.com/palkan","followers_url":"https://api.github.com/users/palkan/followers","following_url":"https://api.github.com/users/palkan/following{/other_user}","gists_url":"https://api.github.com/users/palkan/gists{/gist_id}","starred_url":"https://api.github.com/users/palkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palkan/subscriptions","organizations_url":"https://api.github.com/users/palkan/orgs","repos_url":"https://api.github.com/users/palkan/repos","events_url":"https://api.github.com/users/palkan/events{/privacy}","received_events_url":"https://api.github.com/users/palkan/received_events","type":"User","site_admin":false},"body":"Здесь лучше проверять на совпадение: `expect(flash[:warning]).to match(/.../)`.\r\n\r\nА еще у shoulda-matchers есть специальный матчер https://github.com/thoughtbot/shoulda-matchers/blob/master/lib/shoulda/matchers/action_controller/set_flash_matcher.rb","created_at":"2016-08-17T07:22:22Z","updated_at":"2016-08-17T07:22:22Z","html_url":"https://github.com/AlexanderShvaykin/pro_sample_app/pull/2#discussion_r75073351","pull_request_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls/comments/75073351"},"html":{"href":"https://github.com/AlexanderShvaykin/pro_sample_app/pull/2#discussion_r75073351"},"pull_request":{"href":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls/2","id":81536248,"html_url":"https://github.com/AlexanderShvaykin/pro_sample_app/pull/2","diff_url":"https://github.com/AlexanderShvaykin/pro_sample_app/pull/2.diff","patch_url":"https://github.com/AlexanderShvaykin/pro_sample_app/pull/2.patch","issue_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/issues/2","number":2,"state":"open","locked":false,"title":"Question answer story","user":{"login":"AlexanderShvaykin","id":15276151,"avatar_url":"https://avatars.githubusercontent.com/u/15276151?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexanderShvaykin","html_url":"https://github.com/AlexanderShvaykin","followers_url":"https://api.github.com/users/AlexanderShvaykin/followers","following_url":"https://api.github.com/users/AlexanderShvaykin/following{/other_user}","gists_url":"https://api.github.com/users/AlexanderShvaykin/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexanderShvaykin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexanderShvaykin/subscriptions","organizations_url":"https://api.github.com/users/AlexanderShvaykin/orgs","repos_url":"https://api.github.com/users/AlexanderShvaykin/repos","events_url":"https://api.github.com/users/AlexanderShvaykin/events{/privacy}","received_events_url":"https://api.github.com/users/AlexanderShvaykin/received_events","type":"User","site_admin":false},"body":"реализованы две истории:\r\nПользователь может задавать вопросы\r\nПользователь может ответить на вопросы","created_at":"2016-08-16T20:12:20Z","updated_at":"2016-08-17T07:22:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6951790b37de4506a70dff2d11e76f60d69e1f92","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls/2/commits","review_comments_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls/2/comments","review_comment_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/issues/2/comments","statuses_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/statuses/fd248e4075894da89a1a1eba2dd7470a11c5be85","head":{"label":"AlexanderShvaykin:question_answer_story","ref":"question_answer_story","sha":"fd248e4075894da89a1a1eba2dd7470a11c5be85","user":{"login":"AlexanderShvaykin","id":15276151,"avatar_url":"https://avatars.githubusercontent.com/u/15276151?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexanderShvaykin","html_url":"https://github.com/AlexanderShvaykin","followers_url":"https://api.github.com/users/AlexanderShvaykin/followers","following_url":"https://api.github.com/users/AlexanderShvaykin/following{/other_user}","gists_url":"https://api.github.com/users/AlexanderShvaykin/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexanderShvaykin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexanderShvaykin/subscriptions","organizations_url":"https://api.github.com/users/AlexanderShvaykin/orgs","repos_url":"https://api.github.com/users/AlexanderShvaykin/repos","events_url":"https://api.github.com/users/AlexanderShvaykin/events{/privacy}","received_events_url":"https://api.github.com/users/AlexanderShvaykin/received_events","type":"User","site_admin":false},"repo":{"id":65318743,"name":"pro_sample_app","full_name":"AlexanderShvaykin/pro_sample_app","owner":{"login":"AlexanderShvaykin","id":15276151,"avatar_url":"https://avatars.githubusercontent.com/u/15276151?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexanderShvaykin","html_url":"https://github.com/AlexanderShvaykin","followers_url":"https://api.github.com/users/AlexanderShvaykin/followers","following_url":"https://api.github.com/users/AlexanderShvaykin/following{/other_user}","gists_url":"https://api.github.com/users/AlexanderShvaykin/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexanderShvaykin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexanderShvaykin/subscriptions","organizations_url":"https://api.github.com/users/AlexanderShvaykin/orgs","repos_url":"https://api.github.com/users/AlexanderShvaykin/repos","events_url":"https://api.github.com/users/AlexanderShvaykin/events{/privacy}","received_events_url":"https://api.github.com/users/AlexanderShvaykin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AlexanderShvaykin/pro_sample_app","description":"приложение созданное на курсе \"продвинутый интенсив\"","fork":false,"url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app","forks_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/forks","keys_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/teams","hooks_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/hooks","issue_events_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/issues/events{/number}","events_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/events","assignees_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/assignees{/user}","branches_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/branches{/branch}","tags_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/tags","blobs_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/git/refs{/sha}","trees_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/statuses/{sha}","languages_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/languages","stargazers_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/stargazers","contributors_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/contributors","subscribers_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/subscribers","subscription_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/subscription","commits_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/commits{/sha}","git_commits_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/git/commits{/sha}","comments_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/comments{/number}","issue_comment_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/issues/comments{/number}","contents_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/contents/{+path}","compare_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/merges","archive_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/downloads","issues_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/issues{/number}","pulls_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls{/number}","milestones_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/milestones{/number}","notifications_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/labels{/name}","releases_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/releases{/id}","deployments_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/deployments","created_at":"2016-08-09T18:30:08Z","updated_at":"2016-08-09T18:32:08Z","pushed_at":"2016-08-16T20:12:20Z","git_url":"git://github.com/AlexanderShvaykin/pro_sample_app.git","ssh_url":"git@github.com:AlexanderShvaykin/pro_sample_app.git","clone_url":"https://github.com/AlexanderShvaykin/pro_sample_app.git","svn_url":"https://github.com/AlexanderShvaykin/pro_sample_app","homepage":null,"size":80,"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":"AlexanderShvaykin:master","ref":"master","sha":"ade9e1b2bb4df621798f4365d971baa8518b6644","user":{"login":"AlexanderShvaykin","id":15276151,"avatar_url":"https://avatars.githubusercontent.com/u/15276151?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexanderShvaykin","html_url":"https://github.com/AlexanderShvaykin","followers_url":"https://api.github.com/users/AlexanderShvaykin/followers","following_url":"https://api.github.com/users/AlexanderShvaykin/following{/other_user}","gists_url":"https://api.github.com/users/AlexanderShvaykin/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexanderShvaykin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexanderShvaykin/subscriptions","organizations_url":"https://api.github.com/users/AlexanderShvaykin/orgs","repos_url":"https://api.github.com/users/AlexanderShvaykin/repos","events_url":"https://api.github.com/users/AlexanderShvaykin/events{/privacy}","received_events_url":"https://api.github.com/users/AlexanderShvaykin/received_events","type":"User","site_admin":false},"repo":{"id":65318743,"name":"pro_sample_app","full_name":"AlexanderShvaykin/pro_sample_app","owner":{"login":"AlexanderShvaykin","id":15276151,"avatar_url":"https://avatars.githubusercontent.com/u/15276151?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexanderShvaykin","html_url":"https://github.com/AlexanderShvaykin","followers_url":"https://api.github.com/users/AlexanderShvaykin/followers","following_url":"https://api.github.com/users/AlexanderShvaykin/following{/other_user}","gists_url":"https://api.github.com/users/AlexanderShvaykin/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexanderShvaykin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexanderShvaykin/subscriptions","organizations_url":"https://api.github.com/users/AlexanderShvaykin/orgs","repos_url":"https://api.github.com/users/AlexanderShvaykin/repos","events_url":"https://api.github.com/users/AlexanderShvaykin/events{/privacy}","received_events_url":"https://api.github.com/users/AlexanderShvaykin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AlexanderShvaykin/pro_sample_app","description":"приложение созданное на курсе \"продвинутый интенсив\"","fork":false,"url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app","forks_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/forks","keys_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/teams","hooks_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/hooks","issue_events_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/issues/events{/number}","events_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/events","assignees_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/assignees{/user}","branches_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/branches{/branch}","tags_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/tags","blobs_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/git/refs{/sha}","trees_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/statuses/{sha}","languages_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/languages","stargazers_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/stargazers","contributors_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/contributors","subscribers_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/subscribers","subscription_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/subscription","commits_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/commits{/sha}","git_commits_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/git/commits{/sha}","comments_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/comments{/number}","issue_comment_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/issues/comments{/number}","contents_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/contents/{+path}","compare_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/merges","archive_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/downloads","issues_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/issues{/number}","pulls_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls{/number}","milestones_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/milestones{/number}","notifications_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/labels{/name}","releases_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/releases{/id}","deployments_url":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/deployments","created_at":"2016-08-09T18:30:08Z","updated_at":"2016-08-09T18:32:08Z","pushed_at":"2016-08-16T20:12:20Z","git_url":"git://github.com/AlexanderShvaykin/pro_sample_app.git","ssh_url":"git@github.com:AlexanderShvaykin/pro_sample_app.git","clone_url":"https://github.com/AlexanderShvaykin/pro_sample_app.git","svn_url":"https://github.com/AlexanderShvaykin/pro_sample_app","homepage":null,"size":80,"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/AlexanderShvaykin/pro_sample_app/pulls/2"},"html":{"href":"https://github.com/AlexanderShvaykin/pro_sample_app/pull/2"},"issue":{"href":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/issues/2"},"comments":{"href":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/AlexanderShvaykin/pro_sample_app/statuses/fd248e4075894da89a1a1eba2dd7470a11c5be85"}}}}
{"actor":{"display_login":"palkan"}}