From 3e5b13ae4d2c91ef008a32f2d7c25926f43c9a5e Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sun, 7 Jan 2018 02:28:06 +0100 Subject: [PATCH] Enable RSpec/LetBeforeExamples cop & fix issues Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/LetBeforeExamples --- .rubocop.yml | 3 +++ spec/features/budgets/investments_spec.rb | 7 ++++--- spec/features/comments/legislation_questions_spec.rb | 8 ++++---- spec/models/budget/group_spec.rb | 4 ++-- spec/models/budget/heading_spec.rb | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5a14a23d8..820308375 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -114,4 +114,7 @@ RSpec/IteratedExpectation: Enabled: true RSpec/LeadingSubject: + Enabled: true + +RSpec/LetBeforeExamples: Enabled: true \ No newline at end of file diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index c335c2652..a967a27f4 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -3,9 +3,6 @@ require 'sessions_helper' feature 'Budget Investments' do - context "Concerns" do - it_behaves_like 'notifiable in-app', Budget::Investment - end let(:author) { create(:user, :level_two, username: 'Isabel') } let(:budget) { create(:budget, name: "Big Budget") } @@ -21,6 +18,10 @@ feature 'Budget Investments' do Setting['feature.allow_images'] = nil end + context "Concerns" do + it_behaves_like 'notifiable in-app', Budget::Investment + end + scenario 'Index' do investments = [create(:budget_investment, heading: heading), create(:budget_investment, heading: heading), diff --git a/spec/features/comments/legislation_questions_spec.rb b/spec/features/comments/legislation_questions_spec.rb index 0c9c868ed..b41a9bf47 100644 --- a/spec/features/comments/legislation_questions_spec.rb +++ b/spec/features/comments/legislation_questions_spec.rb @@ -3,14 +3,14 @@ include ActionView::Helpers::DateHelper feature 'Commenting legislation questions' do - context "Concerns" do - it_behaves_like 'notifiable in-app', Legislation::Question - end - let(:user) { create :user, :level_two } let(:process) { create :legislation_process, :in_debate_phase } let(:legislation_question) { create :legislation_question, process: process } + context "Concerns" do + it_behaves_like 'notifiable in-app', Legislation::Question + end + scenario 'Index' do 3.times { create(:comment, commentable: legislation_question) } diff --git a/spec/models/budget/group_spec.rb b/spec/models/budget/group_spec.rb index 4d2570b59..099700c4e 100644 --- a/spec/models/budget/group_spec.rb +++ b/spec/models/budget/group_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' describe Budget::Group do - it_behaves_like "sluggable" - let(:budget) { create(:budget) } + it_behaves_like "sluggable" + describe "name" do before do create(:budget_group, budget: budget, name: 'object name') diff --git a/spec/models/budget/heading_spec.rb b/spec/models/budget/heading_spec.rb index b2f16a153..70787550f 100644 --- a/spec/models/budget/heading_spec.rb +++ b/spec/models/budget/heading_spec.rb @@ -2,11 +2,11 @@ require 'rails_helper' describe Budget::Heading do - it_behaves_like "sluggable" - let(:budget) { create(:budget) } let(:group) { create(:budget_group, budget: budget) } + it_behaves_like "sluggable" + describe "name" do before do create(:budget_heading, group: group, name: 'object name')