Fix RSpec/MissingExampleGroupArgument cop (#25310)

pull/25317/head
Matt Jankowski 2023-06-06 09:51:42 -04:00 committed by GitHub
parent b74c3cd708
commit 6c0e3f490a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 38 additions and 68 deletions

View File

@ -393,30 +393,6 @@ RSpec/MessageSpies:
- 'spec/spec_helper.rb' - 'spec/spec_helper.rb'
- 'spec/validators/status_length_validator_spec.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: RSpec/MultipleExpectations:
Max: 19 Max: 19

View File

@ -99,7 +99,7 @@ RSpec.describe AccountsController do
end end
end end
context do context 'with a normal account in an HTML request' do
before do before do
get :show, params: { username: account.username, format: format } get :show, params: { username: account.username, format: format }
end end
@ -173,7 +173,7 @@ RSpec.describe AccountsController do
end end
end end
context do context 'with a normal account in a JSON request' do
before do before do
get :show, params: { username: account.username, format: format } get :show, params: { username: account.username, format: format }
end end
@ -314,7 +314,7 @@ RSpec.describe AccountsController do
it_behaves_like 'cacheable response' it_behaves_like 'cacheable response'
end end
context do context 'with a normal account in an RSS request' do
before do before do
get :show, params: { username: account.username, format: format } get :show, params: { username: account.username, format: format }
end end

View File

@ -88,7 +88,7 @@ RSpec.describe ActivityPub::CollectionsController do
context 'with signature' do context 'with signature' do
let(:remote_account) { Fabricate(:account, domain: 'example.com') } let(:remote_account) { Fabricate(:account, domain: 'example.com') }
context do context 'when getting a featured resource' do
before do before do
get :show, params: { id: 'featured', account_username: account.username } get :show, params: { id: 'featured', account_username: account.username }
end end

View File

@ -20,7 +20,7 @@ describe Admin::StatusesController do
end end
describe 'GET #index' do describe 'GET #index' do
context do context 'with a valid account' do
before do before do
get :index, params: { account_id: account.id } get :index, params: { account_id: account.id }
end end

View File

@ -40,7 +40,7 @@ describe Admin::Users::RolesController do
put :update, params: { user_id: user.id, user: { role_id: selected_role.id } } put :update, params: { user_id: user.id, user: { role_id: selected_role.id } }
end end
context do context 'with manage roles permissions' do
let(:permissions) { UserRole::FLAGS[:manage_roles] } let(:permissions) { UserRole::FLAGS[:manage_roles] }
let(:position) { 1 } let(:position) { 1 }

View File

@ -73,7 +73,7 @@ RSpec.describe Api::V1::AccountsController do
let(:scopes) { 'write:follows' } let(:scopes) { 'write:follows' }
let(:other_account) { Fabricate(:account, username: 'bob', locked: locked) } let(:other_account) { Fabricate(:account, username: 'bob', locked: locked) }
context do context 'when posting to an other account' do
before do before do
post :follow, params: { id: other_account.id } post :follow, params: { id: other_account.id }
end end

View File

@ -32,7 +32,7 @@ RSpec.describe Api::V1::Admin::AccountActionsController do
end end
describe 'POST #create' do describe 'POST #create' do
context do context 'with type of disable' do
before do before do
post :create, params: { account_id: account.id, type: 'disable' } post :create, params: { account_id: account.id, type: 'disable' }
end end

View File

@ -96,7 +96,7 @@ RSpec.describe Api::V1::Admin::DomainAllowsController do
describe 'POST #create' do describe 'POST #create' do
let!(:domain_allow) { Fabricate(:domain_allow, domain: 'example.com') } let!(:domain_allow) { Fabricate(:domain_allow, domain: 'example.com') }
context do context 'with a valid domain' do
before do before do
post :create, params: { domain: 'foo.bar.com' } post :create, params: { domain: 'foo.bar.com' }
end end

View File

@ -120,7 +120,7 @@ RSpec.describe Api::V1::StatusesController do
describe 'POST #create' do describe 'POST #create' do
let(:scopes) { 'write:statuses' } let(:scopes) { 'write:statuses' }
context do context 'with a basic status body' do
before do before do
post :create, params: { status: 'Hello world' } post :create, params: { status: 'Hello world' }
end end

View File

@ -79,7 +79,7 @@ RSpec.describe Auth::RegistrationsController do
request.env['devise.mapping'] = Devise.mappings[:user] request.env['devise.mapping'] = Devise.mappings[:user]
end end
context do context 'with open registrations' do
around do |example| around do |example|
registrations_mode = Setting.registrations_mode registrations_mode = Setting.registrations_mode
example.run example.run
@ -111,7 +111,7 @@ RSpec.describe Auth::RegistrationsController do
end end
end end
context do context 'when an accept language is present in headers' do
subject do subject do
Setting.registrations_mode = 'open' Setting.registrations_mode = 'open'
request.headers['Accept-Language'] = accept_language request.headers['Accept-Language'] = accept_language

View File

@ -32,7 +32,7 @@ describe 'Log in' do
expect(subject).to have_css('.flash-message', text: failure_message('invalid')) expect(subject).to have_css('.flash-message', text: failure_message('invalid'))
end end
context do context 'when confirmed at is nil' do
let(:confirmed_at) { nil } let(:confirmed_at) { nil }
it 'A unconfirmed user is able to log in' do it 'A unconfirmed user is able to log in' do

View File

@ -31,7 +31,7 @@ RSpec.describe ActivityPub::Activity::Undo do
} }
end end
context do context 'when not atomUri' do
before do before do
Fabricate(:status, reblog: status, account: sender, uri: 'bar') Fabricate(:status, reblog: status, account: sender, uri: 'bar')
end end

View File

@ -71,11 +71,9 @@ describe StatusReachFinder do
bob.statuses.create!(thread: status, text: 'Hoge') bob.statuses.create!(thread: status, text: 'Hoge')
end end
context do
it 'includes the inbox of the replier' do it 'includes the inbox of the replier' do
expect(subject.inboxes).to include 'https://foo.bar/inbox' expect(subject.inboxes).to include 'https://foo.bar/inbox'
end end
end
context 'when status is not public' do context 'when status is not public' do
let(:visibility) { :private } let(:visibility) { :private }
@ -90,11 +88,9 @@ describe StatusReachFinder do
let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') } let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') }
let(:parent_status) { Fabricate(:status, account: bob) } let(:parent_status) { Fabricate(:status, account: bob) }
context do
it 'includes the inbox of the replied-to account' do it 'includes the inbox of the replied-to account' do
expect(subject.inboxes).to include 'https://foo.bar/inbox' expect(subject.inboxes).to include 'https://foo.bar/inbox'
end end
end
context 'when status is not public and replied-to account is not mentioned' do context 'when status is not public and replied-to account is not mentioned' do
let(:visibility) { :private } let(:visibility) { :private }

View File

@ -3,7 +3,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Account do RSpec.describe Account do
context do context 'with an account record' do
subject { Fabricate(:account) } subject { Fabricate(:account) }
let(:bob) { Fabricate(:account, username: 'bob') } let(:bob) { Fabricate(:account, username: 'bob') }

View File

@ -9,7 +9,7 @@ RSpec.describe EmailDomainBlock do
context 'when given an e-mail address' do context 'when given an e-mail address' do
let(:input) { "foo@#{domain}" } let(:input) { "foo@#{domain}" }
context do context 'with a top level domain' do
let(:domain) { 'example.com' } let(:domain) { 'example.com' }
it 'returns true if the domain is blocked' do it 'returns true if the domain is blocked' do
@ -23,7 +23,7 @@ RSpec.describe EmailDomainBlock do
end end
end end
context do context 'with a subdomain' do
let(:domain) { 'mail.example.com' } let(:domain) { 'mail.example.com' }
it 'returns true if it is a subdomain of a blocked domain' do it 'returns true if it is a subdomain of a blocked domain' do

View File

@ -81,7 +81,7 @@ RSpec.describe Trends::Statuses do
4.times { reblog(status3, today) } 4.times { reblog(status3, today) }
end end
context do context 'when status trends are refreshed' do
before do before do
subject.refresh(today) subject.refresh(today)
end end

View File

@ -44,7 +44,7 @@ RSpec.describe Trends::Tags do
4.times { |i| subject.add(tag2, i, today) } 4.times { |i| subject.add(tag2, i, today) }
end end
context do context 'when tag trends are refreshed' do
before do before do
subject.refresh(yesterday + 12.hours) subject.refresh(yesterday + 12.hours)
subject.refresh(at_time) subject.refresh(at_time)

View File

@ -118,12 +118,10 @@ RSpec.describe UserRole do
end end
end end
context do
it 'returns permissions combined with the everyone role' do it 'returns permissions combined with the everyone role' do
expect(subject.computed_permissions).to eq described_class.everyone.permissions expect(subject.computed_permissions).to eq described_class.everyone.permissions
end end
end end
end
describe '.everyone' do describe '.everyone' do
subject { described_class.everyone } subject { described_class.everyone }

View File

@ -363,7 +363,7 @@ RSpec.describe User do
expect(user).to_not be_valid expect(user).to_not be_valid
end end
context do context 'with a blacklisted subdomain' do
around do |example| around do |example|
old_blacklist = Rails.configuration.x.email_blacklist old_blacklist = Rails.configuration.x.email_blacklist
example.run example.run

View File

@ -20,7 +20,7 @@ RSpec.describe FetchLinkCardService, type: :service do
end end
context 'with a local status' do context 'with a local status' do
context do context 'with an IDN url' do
let(:status) { Fabricate(:status, text: 'Check out http://example.中国') } let(:status) { Fabricate(:status, text: 'Check out http://example.中国') }
it 'works with IDN URLs' do it 'works with IDN URLs' do
@ -28,7 +28,7 @@ RSpec.describe FetchLinkCardService, type: :service do
end end
end end
context do context 'with an SJIS url' do
let(:status) { Fabricate(:status, text: 'Check out http://example.com/sjis') } let(:status) { Fabricate(:status, text: 'Check out http://example.com/sjis') }
it 'works with SJIS' do it 'works with SJIS' do
@ -37,7 +37,7 @@ RSpec.describe FetchLinkCardService, type: :service do
end end
end end
context do context 'with invalid SJIS url' do
let(:status) { Fabricate(:status, text: 'Check out http://example.com/sjis_with_wrong_charset') } let(:status) { Fabricate(:status, text: 'Check out http://example.com/sjis_with_wrong_charset') }
it 'works with SJIS even with wrong charset header' do it 'works with SJIS even with wrong charset header' do
@ -46,7 +46,7 @@ RSpec.describe FetchLinkCardService, type: :service do
end end
end end
context do context 'with an koi8-r url' do
let(:status) { Fabricate(:status, text: 'Check out http://example.com/koi8-r') } let(:status) { Fabricate(:status, text: 'Check out http://example.com/koi8-r') }
it 'works with koi8-r' do it 'works with koi8-r' do
@ -55,7 +55,7 @@ RSpec.describe FetchLinkCardService, type: :service do
end end
end end
context do context 'with a windows-1251 url' do
let(:status) { Fabricate(:status, text: 'Check out http://example.com/windows-1251') } let(:status) { Fabricate(:status, text: 'Check out http://example.com/windows-1251') }
it 'works with windows-1251' do it 'works with windows-1251' do
@ -64,7 +64,7 @@ RSpec.describe FetchLinkCardService, type: :service do
end end
end end
context do context 'with a japanese path url' do
let(:status) { Fabricate(:status, text: 'テストhttp://example.com/日本語') } let(:status) { Fabricate(:status, text: 'テストhttp://example.com/日本語') }
it 'works with Japanese path string' do it 'works with Japanese path string' do
@ -73,7 +73,7 @@ RSpec.describe FetchLinkCardService, type: :service do
end end
end end
context do context 'with a hyphen-suffixed url' do
let(:status) { Fabricate(:status, text: 'test http://example.com/test-') } let(:status) { Fabricate(:status, text: 'test http://example.com/test-') }
it 'works with a URL ending with a hyphen' do it 'works with a URL ending with a hyphen' do
@ -81,7 +81,7 @@ RSpec.describe FetchLinkCardService, type: :service do
end end
end end
context do context 'with an isolated url' do
let(:status) { Fabricate(:status, text: 'testhttp://example.com/sjis') } let(:status) { Fabricate(:status, text: 'testhttp://example.com/sjis') }
it 'does not fetch URLs with not isolated from their surroundings' do it 'does not fetch URLs with not isolated from their surroundings' do
@ -89,7 +89,7 @@ RSpec.describe FetchLinkCardService, type: :service do
end end
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') } 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 it 'does fetch URLs with a caret in search params' do

View File

@ -127,7 +127,7 @@ RSpec.describe NotifyService, type: :service do
end end
end end
context do context 'with muted and blocked users' do
let(:asshole) { Fabricate(:account, username: 'asshole') } let(:asshole) { Fabricate(:account, username: 'asshole') }
let(:reply_to) { Fabricate(:status, account: asshole) } let(:reply_to) { Fabricate(:status, account: asshole) }
let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, thread: reply_to)) } 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
end end
context do context 'with sender as recipient' do
let(:sender) { recipient } let(:sender) { recipient }
it 'does not notify when recipient is the sender' do it 'does not notify when recipient is the sender' do

View File

@ -37,7 +37,7 @@ RSpec.describe ProcessMentionsService, type: :service do
let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct}", visibility: :public) } let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct}", visibility: :public) }
context 'with ActivityPub' do 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') } let!(:remote_user) { Fabricate(:account, username: 'remote_user', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
before do before do