A platform for community discussion. Free, open, simple.
DEV: Add rubocop-rspec (#9288)
Jarek Radosz7ff889574d85
diff --git a/.rubocop.yml b/.rubocop.ymlindex f9dafa672c8..f74aa303eed 100644--- a/.rubocop.yml+++ b/.rubocop.yml@@ -1,8 +1,9 @@require:- rubocop-discourse+ - rubocop-rspecAllCops:- TargetRubyVersion: 2.4+ TargetRubyVersion: 2.6DisabledByDefault: trueExclude:- "db/schema.rb"@@ -143,3 +144,212 @@ Style/GlobalVars:- 'script/**/*'- 'spec/**/*.rb'- 'plugins/*/spec/**/*'++# Specs++RSpec/AnyInstance:+ Enabled: false # To be decided++RSpec/AroundBlock:+ Enabled: true++RSpec/BeforeAfterAll:+ Enabled: false # To be decided++RSpec/ContextMethod:+ Enabled: false # TODO++RSpec/ContextWording:+ Enabled: false # To be decided++RSpec/DescribeClass:+ Enabled: false # To be decided++RSpec/DescribeMethod:+ Enabled: true++RSpec/DescribeSymbol:+ Enabled: false # To be decided++RSpec/DescribedClass:+ Enabled: false # To be decided++RSpec/DescribedClassModuleWrapping:+ Enabled: false # To be decided++RSpec/EmptyExampleGroup:+ Enabled: true++RSpec/EmptyLineAfterExample:+ Enabled: false # TODO++RSpec/EmptyLineAfterExampleGroup:+ Enabled: false # TODO++RSpec/EmptyLineAfterFinalLet:+ Enabled: false # TODO++RSpec/EmptyLineAfterHook:+ Enabled: false # TODO++RSpec/EmptyLineAfterSubject:+ Enabled: false # TODO++RSpec/ExampleLength:+ Enabled: false # To be decided++RSpec/ExampleWithoutDescription:+ Enabled: true++RSpec/ExampleWording:+ Enabled: false # TODO++RSpec/ExpectActual:+ Enabled: true++RSpec/ExpectChange:+ Enabled: false # To be decided++RSpec/ExpectInHook:+ Enabled: false # To be decided++RSpec/ExpectOutput:+ Enabled: true++RSpec/FilePath:+ Enabled: false # To be decided++RSpec/Focus:+ Enabled: true++RSpec/HookArgument:+ Enabled: false # TODO++RSpec/HooksBeforeExamples:+ Enabled: false # TODO++RSpec/ImplicitBlockExpectation:+ Enabled: true++RSpec/ImplicitExpect:+ Enabled: false # To be decided++RSpec/ImplicitSubject:+ Enabled: false # To be decided++RSpec/InstanceSpy:+ Enabled: true++RSpec/InstanceVariable:+ Enabled: false # TODO++RSpec/InvalidPredicateMatcher:+ Enabled: true++RSpec/ItBehavesLike:+ Enabled: true++RSpec/IteratedExpectation:+ Enabled: false # To be decided++RSpec/LeadingSubject:+ Enabled: false # TODO++RSpec/LeakyConstantDeclaration:+ Enabled: false # To be decided++RSpec/LetBeforeExamples:+ Enabled: false # TODO++RSpec/LetSetup:+ Enabled: false # TODO++RSpec/MessageChain:+ Enabled: true++RSpec/MessageSpies:+ Enabled: true++RSpec/MissingExampleGroupArgument:+ Enabled: true++RSpec/MultipleDescribes:+ Enabled: false # TODO++RSpec/MultipleSubjects:+ Enabled: true++RSpec/NamedSubject:+ Enabled: false # To be decided++RSpec/NestedGroups:+ Enabled: false # To be decided++RSpec/OverwritingSetup:+ Enabled: true++RSpec/ReceiveCounts:+ Enabled: true++RSpec/ReceiveNever:+ Enabled: true++RSpec/RepeatedDescription:+ Enabled: false # TODO++RSpec/RepeatedExample:+ Enabled: false # TODO++RSpec/RepeatedExampleGroupBody:+ Enabled: false # TODO++RSpec/RepeatedExampleGroupDescription:+ Enabled: false # TODO++RSpec/ReturnFromStub:+ Enabled: true++RSpec/ScatteredSetup:+ Enabled: false # TODO++RSpec/SharedContext:+ Enabled: true++RSpec/SharedExamples:+ Enabled: true++RSpec/SingleArgumentMessageChain:+ Enabled: true++RSpec/SubjectStub:+ Enabled: true++RSpec/UnspecifiedException:+ Enabled: true++RSpec/VerifiedDoubles:+ Enabled: true++RSpec/VoidExpect:+ Enabled: true++RSpec/Yield:+ Enabled: true++Capybara/CurrentPathExpectation:+ Enabled: true++Capybara/FeatureMethods:+ Enabled: true++FactoryBot/AttributeDefinedStatically:+ Enabled: true++FactoryBot/CreateList:+ Enabled: true++FactoryBot/FactoryClassName:+ Enabled: true++Rails/HttpStatus:+ Enabled: truediff --git a/Gemfile b/Gemfileindex 2c0ed01915b..9e4b7cb7bfe 100644--- a/Gemfile+++ b/Gemfile@@ -180,6 +180,7 @@ group :test, :development dogem 'byebug', require: ENV['RM_INFO'].nil?, platform: :mrigem 'rubocop', require: falsegem "rubocop-discourse", require: false+ gem "rubocop-rspec", require: falsegem 'parallel_tests'enddiff --git a/Gemfile.lock b/Gemfile.lockindex cc1ebd682f9..71e97943f9f 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -350,6 +350,8 @@ GEMunicode-display_width (>= 1.4.0, < 1.7)rubocop-discourse (2.0.1)rubocop (>= 0.69.0)+ rubocop-rspec (1.38.1)+ rubocop (>= 0.68.1)ruby-prof (1.3.1)ruby-progressbar (1.10.1)ruby-readability (0.7.0)@@ -527,6 +529,7 @@ DEPENDENCIESrtlitrubocoprubocop-discourse+ rubocop-rspecruby-profruby-readabilityrubyzipdiff --git a/spec/lib/backup_restore/restorer_spec.rb b/spec/lib/backup_restore/restorer_spec.rbdeleted file mode 100644index 47dea3e32d8..00000000000--- a/spec/lib/backup_restore/restorer_spec.rb+++ /dev/null@@ -1,7 +0,0 @@-# frozen_string_literal: true--require 'rails_helper'--describe BackupRestore::Restorer do--enddiff --git a/spec/lib/seed_data/categories_spec.rb b/spec/lib/seed_data/categories_spec.rbindex 90a58cd996b..e848c5ef389 100644--- a/spec/lib/seed_data/categories_spec.rb+++ b/spec/lib/seed_data/categories_spec.rb@@ -33,7 +33,7 @@ describe SeedData::Categories doexpect(category.user_id).to eq(Discourse::SYSTEM_USER_ID)expect(category.category_groups.count).to eq(1)expect(category.category_groups.first).to have_attributes(permissions(:staff, :full))- expect(Topic.exists?(category.topic_id))+ expect(Topic.exists?(category.topic_id)).to eq(true)expect(description_post(category).raw).to eq(I18n.t("staff_category_description"))expect(SiteSetting.staff_category_id).to eq(category.id)enddiff --git a/spec/lib/topic_upload_security_manager_spec.rb b/spec/lib/topic_upload_security_manager_spec.rbindex e0800f503c8..5947ceecabf 100644--- a/spec/lib/topic_upload_security_manager_spec.rb+++ b/spec/lib/topic_upload_security_manager_spec.rb@@ -120,7 +120,7 @@ describe TopicUploadSecurityManager doendit "changes the upload secure status to true and changes the ACL and rebakes the post and sets the access control post" do- expect(Post.any_instance.expects(:rebake!).once)+ Post.any_instance.expects(:rebake!).oncesubject.runexpect(upload3.reload.secure?).to eq(true)expect(upload3.reload.access_control_post).to eq(post4)@@ -146,7 +146,7 @@ describe TopicUploadSecurityManager doendit "does not change the upload secure status and does not set the access control post" do- expect(Post.any_instance.expects(:rebake!).never)+ Post.any_instance.expects(:rebake!).neversubject.runexpect(upload3.reload.secure?).to eq(false)expect(upload3.reload.access_control_post).to eq(nil)@@ -174,14 +174,14 @@ describe TopicUploadSecurityManager doenddef expect_upload_status_not_to_change- expect(Post.any_instance.expects(:rebake!).never)+ Post.any_instance.expects(:rebake!).neversubject.runexpect(upload.reload.secure?).to eq(true)expect(upload2.reload.secure?).to eq(true)enddef expect_upload_status_to_change_and_rebake- expect(Post.any_instance.expects(:rebake!).twice)+ Post.any_instance.expects(:rebake!).twicesubject.runexpect(upload.reload.secure?).to eq(false)expect(upload2.reload.secure?).to eq(false)diff --git a/spec/mailers/user_notifications_spec.rb b/spec/mailers/user_notifications_spec.rbindex dd86e29e3c4..90f6535cb1b 100644--- a/spec/mailers/user_notifications_spec.rb+++ b/spec/mailers/user_notifications_spec.rb@@ -968,7 +968,7 @@ describe UserNotifications doend# notification emails derived from templates are translated into the user's locale- shared_examples "notification derived from template" do+ shared_context "notification derived from template" dolet(:user) { Fabricate(:user, locale: locale) }let(:mail_type) { mail_type }let(:notification) { Fabricate(:notification, user: user) }diff --git a/spec/models/site_setting_spec.rb b/spec/models/site_setting_spec.rbindex 5c8f973ccc2..fc185415451 100644--- a/spec/models/site_setting_spec.rb+++ b/spec/models/site_setting_spec.rb@@ -178,7 +178,7 @@ describe SiteSetting doend.to change { @fake_logger.warnings.count }.by(2)expect do- expect(SiteSetting.use_https(warn: false))+ SiteSetting.use_https(warn: false)end.to_not change { @fake_logger.warnings }SiteSetting.use_https = falsediff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rbindex 64ad9b005d0..d2661162f75 100644--- a/spec/models/topic_spec.rb+++ b/spec/models/topic_spec.rb@@ -1122,7 +1122,7 @@ describe Topic docontext 'closed' dolet(:status) { 'closed' }- it_should_behave_like 'a status that closes a topic'+ it_behaves_like 'a status that closes a topic'it 'should archive group message' dogroup = Fabricate(:group)@@ -1135,7 +1135,7 @@ describe Topic docontext 'autoclosed' dolet(:status) { 'autoclosed' }- it_should_behave_like 'a status that closes a topic'+ it_behaves_like 'a status that closes a topic'context 'topic was set to close when it was created' doit 'includes the autoclose duration in the moderator post' do