From b48678e3325ca135f0d393ffc94cbc08ecc78162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 1 Jul 2019 01:17:16 +0200 Subject: [PATCH] Use `have_link` instead of `have_css("a")` --- spec/features/polls/votation_type_spec.rb | 50 ++++++++++++++--------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/spec/features/polls/votation_type_spec.rb b/spec/features/polls/votation_type_spec.rb index 2bd6ac8b5..f8d65e3a0 100644 --- a/spec/features/polls/votation_type_spec.rb +++ b/spec/features/polls/votation_type_spec.rb @@ -34,8 +34,9 @@ describe "Poll Votation Type" do within("#poll_question_#{unique.id}_answers") do click_link answer1.title - expect(page).to have_css("a", text: answer2.title) - expect(page).not_to have_css("a", text: answer1.title) + + expect(page).to have_link answer2.title + expect(page).not_to have_link answer1.title end end @@ -44,11 +45,14 @@ describe "Poll Votation Type" do within("#poll_question_#{unique.id}_answers") do click_link answer1.title - expect(page).to have_css("a", text: answer2.title) - expect(page).not_to have_css("a", text: answer1.title) + + expect(page).to have_link answer2.title + expect(page).not_to have_link answer1.title + click_link answer2.title - expect(page).to have_css("a", text: answer1.title) - expect(page).not_to have_css("a", text: answer2.title) + + expect(page).to have_link answer1.title + expect(page).not_to have_link answer2.title end end end @@ -84,7 +88,8 @@ describe "Poll Votation Type" do question.question_answers.each do |answer| within("#poll_question_#{question.id}_answers") do click_link answer.title - expect(page).to have_css(".answered", text: answer.title) + + expect(page).to have_link answer.title, class: "answered" end end end @@ -104,7 +109,8 @@ describe "Poll Votation Type" do within("#poll_question_#{question.id}_answers") do click_link answer6.title - expect(page).not_to have_css(".answered", text: answer6.title) + + expect(page).not_to have_link text: answer6.title, class: "answered" end end @@ -128,11 +134,11 @@ describe "Poll Votation Type" do visit poll_path(poll_current) within("#poll_question_#{question.id}_answers") do - expect(page).to have_css("a", text: answer6.title) + expect(page).to have_link answer6.title click_link answer6.title - expect(page).to have_css(".answered", text: answer6.title) + expect(page).to have_link answer6.title, class: "answered" end end end @@ -173,7 +179,7 @@ describe "Poll Votation Type" do question.question_answers.each do |answer| within("#poll_question_#{question.id}_answers") do - expect(page).to have_css("a", text: answer.title) + expect(page).to have_link answer.title end end @@ -194,7 +200,8 @@ describe "Poll Votation Type" do within("#poll_question_#{question.id}_answers") do click_link answer6.title - expect(page).not_to have_css(".answered", text: answer6.title) + + expect(page).not_to have_link answer6.title, class: "answered" end end end @@ -230,7 +237,8 @@ describe "Poll Votation Type" do question.question_answers.each do |answer| within("#poll_question_#{question.id}_answers") do click_link answer.title - expect(page).to have_css(".answered", text: answer.title) + + expect(page).to have_link answer.title, class: "answered" end end end @@ -250,7 +258,8 @@ describe "Poll Votation Type" do within("#poll_question_#{question.id}_answers") do click_link answer6.title - expect(page).not_to have_css(".answered", text: answer6.title) + + expect(page).not_to have_link answer6.title, class: "answered" end end @@ -275,22 +284,25 @@ describe "Poll Votation Type" do within("#poll_question_#{question.id}_answers") do click_link answer6.title - expect(page).to have_css(".answered", text: answer6.title) + + expect(page).to have_link answer6.title, class: "answered" end end scenario "add answer", :js do visit poll_path(poll_current) - fill_in "answer", with: "added_answer" + fill_in "answer", with: "Added answer" click_button "Add answer" visit poll_path(poll_current) within("#poll_question_#{question.id}_answers") do - expect(page).to have_css("a", text: "added_answer") - click_link "added_answer" - expect(page).to have_css(".answered", text: "added_answer") + expect(page).not_to have_link "Added answer", class: "answered" + + click_link "Added answer" + + expect(page).to have_link "Added answer", class: "answered" end end end