From 6c0e3f490a000187c97e94b91264e4f59294b671 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 6 Jun 2023 09:51:42 -0400 Subject: [PATCH] Fix RSpec/MissingExampleGroupArgument cop (#25310) --- .rubocop_todo.yml | 24 ------------------- spec/controllers/accounts_controller_spec.rb | 6 ++--- .../collections_controller_spec.rb | 2 +- .../admin/statuses_controller_spec.rb | 2 +- .../admin/users/roles_controller_spec.rb | 2 +- .../api/v1/accounts_controller_spec.rb | 2 +- .../admin/account_actions_controller_spec.rb | 2 +- .../v1/admin/domain_allows_controller_spec.rb | 2 +- .../api/v1/statuses_controller_spec.rb | 2 +- .../auth/registrations_controller_spec.rb | 4 ++-- spec/features/log_in_spec.rb | 2 +- spec/lib/activitypub/activity/undo_spec.rb | 2 +- spec/lib/status_reach_finder_spec.rb | 12 ++++------ spec/models/account_spec.rb | 2 +- spec/models/email_domain_block_spec.rb | 4 ++-- spec/models/trends/statuses_spec.rb | 2 +- spec/models/trends/tags_spec.rb | 2 +- spec/models/user_role_spec.rb | 6 ++--- spec/models/user_spec.rb | 2 +- spec/services/fetch_link_card_service_spec.rb | 18 +++++++------- spec/services/notify_service_spec.rb | 4 ++-- .../services/process_mentions_service_spec.rb | 2 +- 22 files changed, 38 insertions(+), 68 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0d0fbfac9..02356fdbe 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -393,30 +393,6 @@ RSpec/MessageSpies: - 'spec/spec_helper.rb' - 'spec/validators/status_length_validator_spec.rb' -RSpec/MissingExampleGroupArgument: - Exclude: - - 'spec/controllers/accounts_controller_spec.rb' - - 'spec/controllers/activitypub/collections_controller_spec.rb' - - 'spec/controllers/admin/statuses_controller_spec.rb' - - 'spec/controllers/admin/users/roles_controller_spec.rb' - - 'spec/controllers/api/v1/accounts_controller_spec.rb' - - 'spec/controllers/api/v1/admin/account_actions_controller_spec.rb' - - 'spec/controllers/api/v1/admin/domain_allows_controller_spec.rb' - - 'spec/controllers/api/v1/statuses_controller_spec.rb' - - 'spec/controllers/auth/registrations_controller_spec.rb' - - 'spec/features/log_in_spec.rb' - - 'spec/lib/activitypub/activity/undo_spec.rb' - - 'spec/lib/status_reach_finder_spec.rb' - - 'spec/models/account_spec.rb' - - 'spec/models/email_domain_block_spec.rb' - - 'spec/models/trends/statuses_spec.rb' - - 'spec/models/trends/tags_spec.rb' - - 'spec/models/user_role_spec.rb' - - 'spec/models/user_spec.rb' - - 'spec/services/fetch_link_card_service_spec.rb' - - 'spec/services/notify_service_spec.rb' - - 'spec/services/process_mentions_service_spec.rb' - RSpec/MultipleExpectations: Max: 19 diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index 366756480..5a8585b06 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -99,7 +99,7 @@ RSpec.describe AccountsController do end end - context do + context 'with a normal account in an HTML request' do before do get :show, params: { username: account.username, format: format } end @@ -173,7 +173,7 @@ RSpec.describe AccountsController do end end - context do + context 'with a normal account in a JSON request' do before do get :show, params: { username: account.username, format: format } end @@ -314,7 +314,7 @@ RSpec.describe AccountsController do it_behaves_like 'cacheable response' end - context do + context 'with a normal account in an RSS request' do before do get :show, params: { username: account.username, format: format } end diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb index 887847488..e2802cf56 100644 --- a/spec/controllers/activitypub/collections_controller_spec.rb +++ b/spec/controllers/activitypub/collections_controller_spec.rb @@ -88,7 +88,7 @@ RSpec.describe ActivityPub::CollectionsController do context 'with signature' do let(:remote_account) { Fabricate(:account, domain: 'example.com') } - context do + context 'when getting a featured resource' do before do get :show, params: { id: 'featured', account_username: account.username } end diff --git a/spec/controllers/admin/statuses_controller_spec.rb b/spec/controllers/admin/statuses_controller_spec.rb index fc27f7147..7171c0e88 100644 --- a/spec/controllers/admin/statuses_controller_spec.rb +++ b/spec/controllers/admin/statuses_controller_spec.rb @@ -20,7 +20,7 @@ describe Admin::StatusesController do end describe 'GET #index' do - context do + context 'with a valid account' do before do get :index, params: { account_id: account.id } end diff --git a/spec/controllers/admin/users/roles_controller_spec.rb b/spec/controllers/admin/users/roles_controller_spec.rb index fe2cee01b..97f69a0b0 100644 --- a/spec/controllers/admin/users/roles_controller_spec.rb +++ b/spec/controllers/admin/users/roles_controller_spec.rb @@ -40,7 +40,7 @@ describe Admin::Users::RolesController do put :update, params: { user_id: user.id, user: { role_id: selected_role.id } } end - context do + context 'with manage roles permissions' do let(:permissions) { UserRole::FLAGS[:manage_roles] } let(:position) { 1 } diff --git a/spec/controllers/api/v1/accounts_controller_spec.rb b/spec/controllers/api/v1/accounts_controller_spec.rb index 1cca69de7..992fb0e89 100644 --- a/spec/controllers/api/v1/accounts_controller_spec.rb +++ b/spec/controllers/api/v1/accounts_controller_spec.rb @@ -73,7 +73,7 @@ RSpec.describe Api::V1::AccountsController do let(:scopes) { 'write:follows' } let(:other_account) { Fabricate(:account, username: 'bob', locked: locked) } - context do + context 'when posting to an other account' do before do post :follow, params: { id: other_account.id } end diff --git a/spec/controllers/api/v1/admin/account_actions_controller_spec.rb b/spec/controllers/api/v1/admin/account_actions_controller_spec.rb index 1c976455e..0f39a80b1 100644 --- a/spec/controllers/api/v1/admin/account_actions_controller_spec.rb +++ b/spec/controllers/api/v1/admin/account_actions_controller_spec.rb @@ -32,7 +32,7 @@ RSpec.describe Api::V1::Admin::AccountActionsController do end describe 'POST #create' do - context do + context 'with type of disable' do before do post :create, params: { account_id: account.id, type: 'disable' } end diff --git a/spec/controllers/api/v1/admin/domain_allows_controller_spec.rb b/spec/controllers/api/v1/admin/domain_allows_controller_spec.rb index ca63ea5a7..69aeb6451 100644 --- a/spec/controllers/api/v1/admin/domain_allows_controller_spec.rb +++ b/spec/controllers/api/v1/admin/domain_allows_controller_spec.rb @@ -96,7 +96,7 @@ RSpec.describe Api::V1::Admin::DomainAllowsController do describe 'POST #create' do let!(:domain_allow) { Fabricate(:domain_allow, domain: 'example.com') } - context do + context 'with a valid domain' do before do post :create, params: { domain: 'foo.bar.com' } end diff --git a/spec/controllers/api/v1/statuses_controller_spec.rb b/spec/controllers/api/v1/statuses_controller_spec.rb index ab6f80a61..c2bdba9ac 100644 --- a/spec/controllers/api/v1/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/statuses_controller_spec.rb @@ -120,7 +120,7 @@ RSpec.describe Api::V1::StatusesController do describe 'POST #create' do let(:scopes) { 'write:statuses' } - context do + context 'with a basic status body' do before do post :create, params: { status: 'Hello world' } end diff --git a/spec/controllers/auth/registrations_controller_spec.rb b/spec/controllers/auth/registrations_controller_spec.rb index b52d7c6ce..ec82cd07b 100644 --- a/spec/controllers/auth/registrations_controller_spec.rb +++ b/spec/controllers/auth/registrations_controller_spec.rb @@ -79,7 +79,7 @@ RSpec.describe Auth::RegistrationsController do request.env['devise.mapping'] = Devise.mappings[:user] end - context do + context 'with open registrations' do around do |example| registrations_mode = Setting.registrations_mode example.run @@ -111,7 +111,7 @@ RSpec.describe Auth::RegistrationsController do end end - context do + context 'when an accept language is present in headers' do subject do Setting.registrations_mode = 'open' request.headers['Accept-Language'] = accept_language diff --git a/spec/features/log_in_spec.rb b/spec/features/log_in_spec.rb index 934575ea6..c64e19d2b 100644 --- a/spec/features/log_in_spec.rb +++ b/spec/features/log_in_spec.rb @@ -32,7 +32,7 @@ describe 'Log in' do expect(subject).to have_css('.flash-message', text: failure_message('invalid')) end - context do + context 'when confirmed at is nil' do let(:confirmed_at) { nil } it 'A unconfirmed user is able to log in' do diff --git a/spec/lib/activitypub/activity/undo_spec.rb b/spec/lib/activitypub/activity/undo_spec.rb index b4cbc7196..58e71fc4e 100644 --- a/spec/lib/activitypub/activity/undo_spec.rb +++ b/spec/lib/activitypub/activity/undo_spec.rb @@ -31,7 +31,7 @@ RSpec.describe ActivityPub::Activity::Undo do } end - context do + context 'when not atomUri' do before do Fabricate(:status, reblog: status, account: sender, uri: 'bar') end diff --git a/spec/lib/status_reach_finder_spec.rb b/spec/lib/status_reach_finder_spec.rb index c53ac2799..7181717dc 100644 --- a/spec/lib/status_reach_finder_spec.rb +++ b/spec/lib/status_reach_finder_spec.rb @@ -71,10 +71,8 @@ describe StatusReachFinder do bob.statuses.create!(thread: status, text: 'Hoge') end - context do - it 'includes the inbox of the replier' do - expect(subject.inboxes).to include 'https://foo.bar/inbox' - end + it 'includes the inbox of the replier' do + expect(subject.inboxes).to include 'https://foo.bar/inbox' end context 'when status is not public' do @@ -90,10 +88,8 @@ describe StatusReachFinder do let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') } let(:parent_status) { Fabricate(:status, account: bob) } - context do - it 'includes the inbox of the replied-to account' do - expect(subject.inboxes).to include 'https://foo.bar/inbox' - end + it 'includes the inbox of the replied-to account' do + expect(subject.inboxes).to include 'https://foo.bar/inbox' end context 'when status is not public and replied-to account is not mentioned' do diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index d966bffa9..7cd914774 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' RSpec.describe Account do - context do + context 'with an account record' do subject { Fabricate(:account) } let(:bob) { Fabricate(:account, username: 'bob') } diff --git a/spec/models/email_domain_block_spec.rb b/spec/models/email_domain_block_spec.rb index 9d9c74887..5874c5e53 100644 --- a/spec/models/email_domain_block_spec.rb +++ b/spec/models/email_domain_block_spec.rb @@ -9,7 +9,7 @@ RSpec.describe EmailDomainBlock do context 'when given an e-mail address' do let(:input) { "foo@#{domain}" } - context do + context 'with a top level domain' do let(:domain) { 'example.com' } it 'returns true if the domain is blocked' do @@ -23,7 +23,7 @@ RSpec.describe EmailDomainBlock do end end - context do + context 'with a subdomain' do let(:domain) { 'mail.example.com' } it 'returns true if it is a subdomain of a blocked domain' do diff --git a/spec/models/trends/statuses_spec.rb b/spec/models/trends/statuses_spec.rb index 29a20a595..cea5dc5e0 100644 --- a/spec/models/trends/statuses_spec.rb +++ b/spec/models/trends/statuses_spec.rb @@ -81,7 +81,7 @@ RSpec.describe Trends::Statuses do 4.times { reblog(status3, today) } end - context do + context 'when status trends are refreshed' do before do subject.refresh(today) end diff --git a/spec/models/trends/tags_spec.rb b/spec/models/trends/tags_spec.rb index 09ac918d0..79cdee346 100644 --- a/spec/models/trends/tags_spec.rb +++ b/spec/models/trends/tags_spec.rb @@ -44,7 +44,7 @@ RSpec.describe Trends::Tags do 4.times { |i| subject.add(tag2, i, today) } end - context do + context 'when tag trends are refreshed' do before do subject.refresh(yesterday + 12.hours) subject.refresh(at_time) diff --git a/spec/models/user_role_spec.rb b/spec/models/user_role_spec.rb index 16bb4358e..27b967414 100644 --- a/spec/models/user_role_spec.rb +++ b/spec/models/user_role_spec.rb @@ -118,10 +118,8 @@ RSpec.describe UserRole do end end - context do - it 'returns permissions combined with the everyone role' do - expect(subject.computed_permissions).to eq described_class.everyone.permissions - end + it 'returns permissions combined with the everyone role' do + expect(subject.computed_permissions).to eq described_class.everyone.permissions end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 554e7efb6..bb61c02a6 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -363,7 +363,7 @@ RSpec.describe User do expect(user).to_not be_valid end - context do + context 'with a blacklisted subdomain' do around do |example| old_blacklist = Rails.configuration.x.email_blacklist example.run diff --git a/spec/services/fetch_link_card_service_spec.rb b/spec/services/fetch_link_card_service_spec.rb index 6495b323c..133d66441 100644 --- a/spec/services/fetch_link_card_service_spec.rb +++ b/spec/services/fetch_link_card_service_spec.rb @@ -20,7 +20,7 @@ RSpec.describe FetchLinkCardService, type: :service do end context 'with a local status' do - context do + context 'with an IDN url' do let(:status) { Fabricate(:status, text: 'Check out http://example.中国') } it 'works with IDN URLs' do @@ -28,7 +28,7 @@ RSpec.describe FetchLinkCardService, type: :service do end end - context do + context 'with an SJIS url' do let(:status) { Fabricate(:status, text: 'Check out http://example.com/sjis') } it 'works with SJIS' do @@ -37,7 +37,7 @@ RSpec.describe FetchLinkCardService, type: :service do end end - context do + context 'with invalid SJIS url' do let(:status) { Fabricate(:status, text: 'Check out http://example.com/sjis_with_wrong_charset') } it 'works with SJIS even with wrong charset header' do @@ -46,7 +46,7 @@ RSpec.describe FetchLinkCardService, type: :service do end end - context do + context 'with an koi8-r url' do let(:status) { Fabricate(:status, text: 'Check out http://example.com/koi8-r') } it 'works with koi8-r' do @@ -55,7 +55,7 @@ RSpec.describe FetchLinkCardService, type: :service do end end - context do + context 'with a windows-1251 url' do let(:status) { Fabricate(:status, text: 'Check out http://example.com/windows-1251') } it 'works with windows-1251' do @@ -64,7 +64,7 @@ RSpec.describe FetchLinkCardService, type: :service do end end - context do + context 'with a japanese path url' do let(:status) { Fabricate(:status, text: 'テストhttp://example.com/日本語') } it 'works with Japanese path string' do @@ -73,7 +73,7 @@ RSpec.describe FetchLinkCardService, type: :service do end end - context do + context 'with a hyphen-suffixed url' do let(:status) { Fabricate(:status, text: 'test http://example.com/test-') } it 'works with a URL ending with a hyphen' do @@ -81,7 +81,7 @@ RSpec.describe FetchLinkCardService, type: :service do end end - context do + context 'with an isolated url' do let(:status) { Fabricate(:status, text: 'testhttp://example.com/sjis') } it 'does not fetch URLs with not isolated from their surroundings' do @@ -89,7 +89,7 @@ RSpec.describe FetchLinkCardService, type: :service do end end - context do + context 'with a url that has a caret' do let(:status) { Fabricate(:status, text: 'test http://example.com/test?data=file.gpx^1') } it 'does fetch URLs with a caret in search params' do diff --git a/spec/services/notify_service_spec.rb b/spec/services/notify_service_spec.rb index 8c99431fa..8fcb58658 100644 --- a/spec/services/notify_service_spec.rb +++ b/spec/services/notify_service_spec.rb @@ -127,7 +127,7 @@ RSpec.describe NotifyService, type: :service do end end - context do + context 'with muted and blocked users' do let(:asshole) { Fabricate(:account, username: 'asshole') } let(:reply_to) { Fabricate(:status, account: asshole) } let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, thread: reply_to)) } @@ -144,7 +144,7 @@ RSpec.describe NotifyService, type: :service do end end - context do + context 'with sender as recipient' do let(:sender) { recipient } it 'does not notify when recipient is the sender' do diff --git a/spec/services/process_mentions_service_spec.rb b/spec/services/process_mentions_service_spec.rb index a28b6db40..0db73c41f 100644 --- a/spec/services/process_mentions_service_spec.rb +++ b/spec/services/process_mentions_service_spec.rb @@ -37,7 +37,7 @@ RSpec.describe ProcessMentionsService, type: :service do let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct}", visibility: :public) } context 'with ActivityPub' do - context do + context 'with a valid remote user' do let!(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } before do