Added first poll results tests

This commit is contained in:
María Checa
2017-10-19 12:17:49 +02:00
parent f029cc2016
commit 8be8bb07f9
3 changed files with 31 additions and 5 deletions

View File

@@ -0,0 +1,26 @@
require 'rails_helper'
feature 'Poll Results' do
scenario 'List each Poll question' do
user = create(:user, :level_two)
poll = create(:poll)
question1 = create(:poll_question, poll: poll)
answer1 = create(:poll_question_answer, question: question1, title: 'Yes')
answer2 = create(:poll_question_answer, question: question1, title: 'No')
question2 = create(:poll_question, poll: poll)
answer3 = create(:poll_question_answer, question: question2, title: 'Blue')
answer4 = create(:poll_question_answer, question: question2, title: 'Green')
answer5 = create(:poll_question_answer, question: question2, title: 'Yellow')
login_as user
vote_for_poll_via_web(poll, question1, 'Yes')
vote_for_poll_via_web(poll, question1, 'Blue')
visit poll_results_path(poll)
expect(page).to have_content(question1.title)
expect(page).to have_content(question2.title)
end
end

View File

@@ -95,7 +95,7 @@ feature "Voter" do
scenario "Trying to vote in web and then in booth", :js do
login_as user
vote_for_poll_via_web(poll, question)
vote_for_poll_via_web(poll, question, 'Yes')
click_link "Sign out"
@@ -127,7 +127,7 @@ feature "Voter" do
scenario "Trying to vote in web again", :js do
login_as user
vote_for_poll_via_web(poll, question)
vote_for_poll_via_web(poll, question, 'Yes')
visit poll_path(poll)

View File

@@ -299,12 +299,12 @@ module CommonActions
end
end
def vote_for_poll_via_web(poll, question)
def vote_for_poll_via_web(poll, question, answer)
visit poll_path(poll)
within("#poll_question_#{question.id}_answers") do
click_link 'Yes'
expect(page).to_not have_link('Yes')
click_link "#{answer}"
expect(page).to_not have_link("#{answer}")
end
expect(Poll::Voter.count).to eq(1)