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.
This commit is contained in:
Javi Martín
2019-06-19 14:18:33 +02:00
parent 765d405df1
commit bd85aede99
9 changed files with 37 additions and 31 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,6 +1,6 @@
require "rails_helper"
feature "Legislation" do
describe "Legislation" do
context "process resume page" do
scenario "resume tab not show" do

View File

@@ -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

View File

@@ -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

View File

@@ -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)