From bd85aede99076de9a3c94227ffd17db4858c850d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 19 Jun 2019 14:18:33 +0200 Subject: [PATCH] Use `describe` on new feature tests The `type: :feature` is automatically detected by RSpec because these tests are inside the `spec/features` folder. Using `feature` re-adds a `type: :feature` to these files, which will result in a conflict when we upgrade to Rails 5.1's system tests. Because of this change, we also need to change `background` to `before` or else these tests will fail. We're also adding a rubocop rule so we dont' accidentally add these keywords again. --- .rubocop_basic.yml | 6 ++++++ spec/features/admin/change_log_spec.rb | 4 ++-- spec/features/admin/download_settings_spec.rb | 12 ++++++------ .../admin/local_census_records/imports_spec.rb | 4 ++-- .../admin/local_census_records_spec.rb | 6 +++--- spec/features/legislation/resume_spec.rb | 2 +- spec/features/polls/votation_type_spec.rb | 12 ++++++------ .../tracking/budget_investments_spec.rb | 18 +++++++++--------- spec/features/tracking/budgets_spec.rb | 4 ++-- 9 files changed, 37 insertions(+), 31 deletions(-) diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index 41c7a619d..cd71adb58 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -14,6 +14,12 @@ AllCops: # to ignore them, so only the ones explicitly set in this file are enabled. DisabledByDefault: true +Capybara/FeatureMethods: + Enabled: true + EnabledMethods: + - scenario + - xscenario + Layout/IndentationConsistency: EnforcedStyle: rails diff --git a/spec/features/admin/change_log_spec.rb b/spec/features/admin/change_log_spec.rb index 288c0d5d0..684d94038 100644 --- a/spec/features/admin/change_log_spec.rb +++ b/spec/features/admin/change_log_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -feature "Admin change log" do +describe "Admin change log" do let(:budget) {create(:budget)} let(:administrator) do create(:administrator, user: create(:user, username: "Ana", email: "ana@admins.org")) @@ -8,7 +8,7 @@ feature "Admin change log" do context "Investments Participatory Budgets" do - background do + before do @admin = create(:administrator) login_as(@admin.user) end diff --git a/spec/features/admin/download_settings_spec.rb b/spec/features/admin/download_settings_spec.rb index 7891db1ee..28cffa683 100644 --- a/spec/features/admin/download_settings_spec.rb +++ b/spec/features/admin/download_settings_spec.rb @@ -1,8 +1,8 @@ require "rails_helper" -feature "Admin download settings" do +describe "Admin download settings" do - background do + before do admin = create(:administrator) login_as(admin.user) end @@ -31,7 +31,7 @@ feature "Admin download settings" do context "Download debates" do - background do + before do create(:debate) end @@ -84,7 +84,7 @@ feature "Admin download settings" do context "Download proposals" do - background do + before do create(:proposal) end @@ -177,7 +177,7 @@ feature "Admin download settings" do context "Download legislation process" do - background do + before do create(:legislation_process, :open) create(:legislation_process, :published) end @@ -286,7 +286,7 @@ feature "Admin download settings" do ballot_lines_count: 600) } let(:budget) {create :budget} - background do + before do Budget::Result.new(budget_finished, heading).calculate_winners end diff --git a/spec/features/admin/local_census_records/imports_spec.rb b/spec/features/admin/local_census_records/imports_spec.rb index 76d990d8b..6b22cba4f 100644 --- a/spec/features/admin/local_census_records/imports_spec.rb +++ b/spec/features/admin/local_census_records/imports_spec.rb @@ -1,10 +1,10 @@ require "rails_helper" -feature "Imports", type: :feature do +describe "Imports" do let(:base_files_path) { %w[spec fixtures files local_census_records import] } - background do + before do admin = create(:administrator) login_as(admin.user) end diff --git a/spec/features/admin/local_census_records_spec.rb b/spec/features/admin/local_census_records_spec.rb index b763378d2..fa5db3dee 100644 --- a/spec/features/admin/local_census_records_spec.rb +++ b/spec/features/admin/local_census_records_spec.rb @@ -1,8 +1,8 @@ require "rails_helper" -feature "Admin local census records" do +describe "Admin local census records" do - background do + before do login_as(create(:administrator).user) end @@ -50,7 +50,7 @@ feature "Admin local census records" do end context "Search" do - background do + before do create(:local_census_record, document_number: "X66777888" ) end diff --git a/spec/features/legislation/resume_spec.rb b/spec/features/legislation/resume_spec.rb index 4ffd87a9c..c61112336 100644 --- a/spec/features/legislation/resume_spec.rb +++ b/spec/features/legislation/resume_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -feature "Legislation" do +describe "Legislation" do context "process resume page" do scenario "resume tab not show" do diff --git a/spec/features/polls/votation_type_spec.rb b/spec/features/polls/votation_type_spec.rb index 255a52e5c..a7922ec57 100644 --- a/spec/features/polls/votation_type_spec.rb +++ b/spec/features/polls/votation_type_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -feature "Poll Votation Type" do +describe "Poll Votation Type" do context "Unique" do @@ -10,7 +10,7 @@ feature "Poll Votation Type" do let!(:answer1) { create(:poll_question_answer, question: unique, title: "answer_1") } let!(:answer2) { create(:poll_question_answer, question: unique, title: "answer_2") } - background do + before do login_as(user) end @@ -64,7 +64,7 @@ feature "Poll Votation Type" do let!(:answer4) { create(:poll_question_answer, question: question, title: "answer_4") } let!(:answer5) { create(:poll_question_answer, question: question, title: "answer_5") } - background do + before do login_as(user) end @@ -148,7 +148,7 @@ feature "Poll Votation Type" do let!(:answer4) { create(:poll_question_answer, question: question, title: "answer_4") } let!(:answer5) { create(:poll_question_answer, question: question, title: "answer_5") } - background do + before do login_as(user) end @@ -210,7 +210,7 @@ feature "Poll Votation Type" do let!(:answer4) { create(:poll_question_answer, question: question, title: "answer_4") } let!(:answer5) { create(:poll_question_answer, question: question, title: "answer_5") } - background do + before do login_as(user) end @@ -306,7 +306,7 @@ feature "Poll Votation Type" do let!(:answer4) { create(:poll_question_answer, question: question, title: "answer_4") } let!(:answer5) { create(:poll_question_answer, question: question, title: "answer_5") } - background do + before do login_as(user) end diff --git a/spec/features/tracking/budget_investments_spec.rb b/spec/features/tracking/budget_investments_spec.rb index eab8424e7..8dad71d2c 100644 --- a/spec/features/tracking/budget_investments_spec.rb +++ b/spec/features/tracking/budget_investments_spec.rb @@ -1,13 +1,13 @@ require "rails_helper" -feature "Valuation budget investments" do +describe "Valuation budget investments" do let(:budget) { create(:budget) } let(:tracker) do create(:tracker, user: create(:user, username: "Rachel", email: "rachel@trackers.org")) end - background do + before do login_as(tracker.user) end @@ -23,7 +23,7 @@ feature "Valuation budget investments" do expect(page).to have_link "Tracking", href: tracking_root_path end - feature "Index" do + describe "Index" do scenario "Index shows budget investments assigned to current tracker" do investment1 = create(:budget_investment, budget: budget) investment2 = create(:budget_investment, budget: budget) @@ -108,7 +108,7 @@ feature "Valuation budget investments" do end end - feature "Show" do + describe "Show" do let(:administrator) do create(:administrator, user: create(:user, username: "Ana", email: "ana@admins.org")) end @@ -119,7 +119,7 @@ feature "Valuation budget investments" do create(:budget_investment, budget: budget, administrator: administrator) end - background do + before do investment.trackers << [tracker, second_tracker] end @@ -168,7 +168,7 @@ feature "Valuation budget investments" do end - feature "Milestones" do + describe "Milestones" do let(:admin) { create(:administrator) } let(:investment) do heading = create(:budget_heading) @@ -176,7 +176,7 @@ feature "Valuation budget investments" do administrator: admin) end - background do + before do investment.trackers << tracker end @@ -250,7 +250,7 @@ feature "Valuation budget investments" do end - feature "Progress Bars" do + describe "Progress Bars" do let(:admin) { create(:administrator) } let(:investment) do @@ -259,7 +259,7 @@ feature "Valuation budget investments" do administrator: admin) end - background do + before do investment.trackers << tracker end diff --git a/spec/features/tracking/budgets_spec.rb b/spec/features/tracking/budgets_spec.rb index ab24069dd..b6fb44890 100644 --- a/spec/features/tracking/budgets_spec.rb +++ b/spec/features/tracking/budgets_spec.rb @@ -1,8 +1,8 @@ require "rails_helper" -feature "Tracking budgets" do +describe "Tracking budgets" do - background do + before do @tracker = create(:tracker, user: create(:user, username: "Rachel", email: "rachel@trackers.org")) login_as(@tracker.user)