Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RSpec/MissingExampleGroupArgument cop #25310

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 0 additions & 24 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/accounts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
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
Expand Down Expand Up @@ -173,7 +173,7 @@
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
Expand Down Expand Up @@ -314,7 +314,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/admin/statuses_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
end

describe 'GET #index' do
context do
context 'with a valid account' do
before do
get :index, params: { account_id: account.id }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/admin/users/roles_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
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 }

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/api/v1/accounts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/api/v1/statuses_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
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
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/auth/registrations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
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
Expand Down Expand Up @@ -111,7 +111,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/features/log_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/activitypub/activity/undo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}
end

context do
context 'when not atomUri' do
before do
Fabricate(:status, reblog: status, account: sender, uri: 'bar')
end
Expand Down
12 changes: 4 additions & 8 deletions spec/lib/status_reach_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,8 @@
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
Expand All @@ -90,10 +88,8 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/models/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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') }
Expand Down
4 changes: 2 additions & 2 deletions spec/models/email_domain_block_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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
Expand All @@ -23,7 +23,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/models/trends/statuses_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
4.times { reblog(status3, today) }
end

context do
context 'when status trends are refreshed' do
before do
subject.refresh(today)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/trends/tags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
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)
Expand Down
6 changes: 2 additions & 4 deletions spec/models/user_role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,8 @@
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

Expand Down
2 changes: 1 addition & 1 deletion spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@
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
Expand Down
18 changes: 9 additions & 9 deletions spec/services/fetch_link_card_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
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
expect(a_request(:get, 'http://example.xn--fiqs8s/')).to have_been_made.at_least_once
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
Expand All @@ -37,7 +37,7 @@
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
Expand All @@ -46,7 +46,7 @@
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
Expand All @@ -55,7 +55,7 @@
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
Expand All @@ -64,7 +64,7 @@
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
Expand All @@ -73,23 +73,23 @@
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
expect(a_request(:get, 'http://example.com/test-')).to have_been_made.at_least_once
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
expect(a_request(:get, 'http://example.com/sjis')).to_not have_been_made
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
Expand Down
4 changes: 2 additions & 2 deletions spec/services/notify_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
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)) }
Expand All @@ -144,7 +144,7 @@
end
end

context do
context 'with sender as recipient' do
let(:sender) { recipient }

it 'does not notify when recipient is the sender' do
Expand Down
2 changes: 1 addition & 1 deletion spec/services/process_mentions_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
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
Expand Down