diff --git a/spec/features/polls/answers_spec.rb b/spec/features/polls/answers_spec.rb index 88b7e28aa..8bb87c94e 100644 --- a/spec/features/polls/answers_spec.rb +++ b/spec/features/polls/answers_spec.rb @@ -2,20 +2,20 @@ require 'rails_helper' feature 'Answers' do + let(:question) { create(:poll_question) } + let(:admin) { create(:administrator) } + background do - admin = create(:administrator) login_as(admin.user) end scenario "Index" do - question = create(:poll_question) answer1 = create(:poll_question_answer, question: question, given_order: 2) answer2 = create(:poll_question_answer, question: question, given_order: 1) visit admin_question_path(question) expect(page).to have_css(".poll_question_answer", count: 2) - expect(page.body.index(answer1.title)).to be < page.body.index(answer2.title) within("#poll_question_answer_#{answer1.id}") do @@ -25,8 +25,6 @@ feature 'Answers' do end scenario "Create" do - question = create(:poll_question) - visit admin_question_path(question) click_link "Add answer" @@ -35,15 +33,12 @@ feature 'Answers' do click_button "Save" expect(page).to have_content "Answer created successfully" - expect(page).to have_css(".poll_question_answer", count: 1) expect(page).to have_content "¿Would you like to reform Central Park?" expect(page).to have_content "Adding more trees, creating a play area..." end - scenario 'Add video to answer' do - question = create(:poll_question) answer1 = create(:poll_question_answer, question: question) answer2 = create(:poll_question_answer, question: question) @@ -60,7 +55,7 @@ feature 'Answers' do click_button "Save" - within("#poll_question_answer_video_#{answer1.id}") do + within("#poll_question_answer_video_#{answer1.videos.last.id}") do expect(page).to have_content "Awesome project video" expect(page).to have_content "https://www.youtube.com/watch?v=123" end