From 3c9953e9e03e4b9dd1bf98838ee7ff5ccbd2822e Mon Sep 17 00:00:00 2001 From: Marko Lovic Date: Tue, 10 Jul 2018 09:24:37 +0200 Subject: [PATCH] Make content assertion order-independent --- spec/features/budgets/votes_spec.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/features/budgets/votes_spec.rb b/spec/features/budgets/votes_spec.rb index 5ab1550e7..d91ad1aa7 100644 --- a/spec/features/budgets/votes_spec.rb +++ b/spec/features/budgets/votes_spec.rb @@ -142,7 +142,10 @@ feature 'Votes' do within("#budget_investment_#{third_heading_investment.id}") do find('.in-favor a').click - expect(page).to have_content "You can only support investment projects in 2 districts. You have already supported investments in #{new_york.name} and #{san_francisco.name}" + expect(page).to have_content "You can only support investment projects in 2 districts. You have already supported investments in" + + heading_names = find('.participation-not-allowed').text.match(/You have already supported investments in (.+) and (.+)\./)&.captures + expect(heading_names).to match_array [new_york.name, san_francisco.name] expect(page).not_to have_content "1 support" expect(page).not_to have_content "You have already supported this investment project. Share it!" @@ -165,7 +168,10 @@ feature 'Votes' do visit budget_investment_path(budget, third_heading_investment) find('.in-favor a').click - expect(page).to have_content "You can only support investment projects in 2 districts. You have already supported investments in #{new_york.name} and #{san_francisco.name}" + expect(page).to have_content "You can only support investment projects in 2 districts. You have already supported investments in" + + heading_names = find('.participation-not-allowed').text.match(/You have already supported investments in (.+) and (.+)\./)&.captures + expect(heading_names).to match_array [new_york.name, san_francisco.name] expect(page).not_to have_content "1 support" expect(page).not_to have_content "You have already supported this investment project. Share it!"