From 32504b884041245ec130cc12931a2d6700168e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Mart=C3=ADn?= Date: Fri, 13 Jul 2018 22:51:17 +0200 Subject: [PATCH] Make Capybara check the page between votes. As pointed out in PR #2734: "After clicking the first link, there's an AJAX request which replaces the existing `.in-favor a` and `.against a` links with new elements. So if Capybara tries to click the existing `.against a` link at the same moment it's being replaced, clicking the link won't generate a new request". Making Capybara check the page for new content before clicking the second link solves the problem, in the same way 4ddc869 solved the same problem in the comments section. --- spec/features/votes_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/features/votes_spec.rb b/spec/features/votes_spec.rb index c837deebf..1ebdcfc91 100644 --- a/spec/features/votes_spec.rb +++ b/spec/features/votes_spec.rb @@ -83,6 +83,12 @@ feature 'Votes' do visit debate_path(create(:debate)) find('.in-favor a').click + + within('.in-favor') do + expect(page).to have_content "100%" + expect(page).to have_css("a.voted") + end + find('.against a').click within('.in-favor') do