Fix RSpec/NoExpectationExample cop (#25103)

lolsob-rspec
Matt Jankowski 2023-05-26 03:41:12 -04:00 committed by GitHub
parent a19c1671af
commit 1411f75aae
3 changed files with 21 additions and 11 deletions

View File

@ -528,13 +528,6 @@ RSpec/MultipleMemoizedHelpers:
RSpec/NestedGroups:
Max: 6
# Configuration parameters: AllowedPatterns.
# AllowedPatterns: ^expect_, ^assert_
RSpec/NoExpectationExample:
Exclude:
- 'spec/controllers/auth/registrations_controller_spec.rb'
- 'spec/services/precompute_feed_service_spec.rb'
RSpec/PendingWithoutReason:
Exclude:
- 'spec/models/account_spec.rb'

View File

@ -244,9 +244,26 @@ RSpec.describe Auth::RegistrationsController do
end
end
it 'does nothing if user already exists' do
context 'with an already taken username' do
subject do
Setting.registrations_mode = 'open'
post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } }
end
before do
Fabricate(:account, username: 'test')
end
it 'responds with an error message about the username' do
subject
expect(response).to have_http_status(:success)
expect(username_error_text).to eq(I18n.t('errors.messages.taken'))
end
def username_error_text
Nokogiri::Slop(response.body).css('.user_account_username .error').text
end
end
include_examples 'checks for enabled registrations', :create

View File

@ -19,7 +19,7 @@ RSpec.describe PrecomputeFeedService, type: :service do
it 'does not raise an error even if it could not find any status' do
account = Fabricate(:account)
subject.call(account)
expect { subject.call(account) }.to_not raise_error
end
it 'filters statuses' do