Skip to content

Commit

Permalink
🔧 Ajoute rubocop-rspec
Browse files Browse the repository at this point in the history
Cela permettra entre-autre de ne plus avoir de focus qui traine dans les tests

J'ai fait la commande `bundle exec rubocop --auto-gen-config` pour mettre les règles qui ne peuvent pas se corriger rapidement dans le fichier .rubocop_todo.yml.
Il faudra se prévoir un temps pour cleaner cela
  • Loading branch information
cprodhomme authored and etienneCharignon committed Sep 27, 2024
1 parent 5c2b369 commit 12db9e5
Show file tree
Hide file tree
Showing 95 changed files with 829 additions and 535 deletions.
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
inherit_from: .rubocop_todo.yml

require:
- rubocop-packaging
- rubocop-rails
- rubocop-rspec

AllCops:
TargetRubyVersion: 2.7
Expand Down Expand Up @@ -65,3 +68,8 @@ Rails/RedundantPresenceValidationOnBelongsTo:
Lint/MissingSuper:
Exclude:
- 'app/components/**/*'

RSpec/DescribeClass:
Exclude:
- 'spec/views/**/*'
- 'spec/tasks/**/*'
192 changes: 192 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-09-27 09:21:59 UTC using RuboCop version 1.66.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 12
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Exclude:
- 'spec/features/admin/evaluation_spec.rb'
- 'spec/integrations/structure_spec.rb'
- 'spec/models/restitution/controle/comprehension_consigne_spec.rb'
- 'spec/models/restitution/controle/perseverance_spec.rb'
- 'spec/models/restitution/inventaire/perseverance_spec.rb'
- 'spec/models/restitution/inventaire/vigilance_controle_spec.rb'
- 'spec/models/restitution/maintenance/score_vocabulaire_spec.rb'
- 'spec/models/restitution/tri/comprehension_consigne_spec.rb'

# Offense count: 7
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/BeEq:
Exclude:
- 'spec/models/question_glisser_deposer_spec.rb'

# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: NegatedMatcher.
RSpec/ChangeByZero:
Exclude:
- 'spec/models/fabrique_evenement_spec.rb'

# Offense count: 616
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Enabled: false

# Offense count: 145
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 38

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
RSpec/ExpectActual:
Exclude:
- 'spec/models/structure_spec.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: method_call, block
RSpec/ExpectChange:
Exclude:
- 'spec/models/question_glisser_deposer_spec.rb'

# Offense count: 4
RSpec/ExpectInHook:
Exclude:
- 'spec/features/admin/campagne_spec.rb'
- 'spec/models/restitution/inventaire/rapidite_spec.rb'

# Offense count: 12
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, each, example
RSpec/HookArgument:
Exclude:
- 'spec/models/question_glisser_deposer_spec.rb'

# Offense count: 64
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
RSpec/IndexedLet:
Enabled: false

# Offense count: 7
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
- 'spec/controllers/eva/devise/session_controller_spec.rb'
- 'spec/models/restitution/inventaire_spec.rb'

# Offense count: 113
RSpec/LetSetup:
Enabled: false

# Offense count: 124
# Configuration parameters: EnforcedStyle.
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Enabled: false

# Offense count: 277
RSpec/MultipleExpectations:
Max: 22

# Offense count: 206
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 22

# Offense count: 103
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Enabled: false

# Offense count: 114
# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 7

# Offense count: 13
# Configuration parameters: AllowedPatterns.
# AllowedPatterns: ^expect_, ^assert_
RSpec/NoExpectationExample:
Exclude:
- 'spec/features/nouvelle_structure_spec.rb'
- 'spec/models/restitution/inventaire/organisation_methode_spec.rb'

# Offense count: 3
RSpec/OverwritingSetup:
Exclude:
- 'spec/jobs/notification_admin_comptes_en_attente_job_spec.rb'
- 'spec/models/restitution/bienvenue_spec.rb'
- 'spec/models/restitution/illettrisme/nombre_reponses_spec.rb'

# Offense count: 2
RSpec/RepeatedExampleGroupBody:
Exclude:
- 'spec/models/restitution/maintenance/temps_non_mots_spec.rb'

# Offense count: 2
RSpec/RepeatedExampleGroupDescription:
Exclude:
- 'spec/models/statistiques_structure_spec.rb'

# Offense count: 9
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
# Include: **/*_spec.rb
RSpec/SpecFilePathFormat:
Exclude:
- 'spec/controllers/eva/devise/session_controller_spec.rb'
- 'spec/controllers/evaluations_controller_spec.rb'
- 'spec/controllers/evenements_controller_spec.rb'
- 'spec/integrations/standardisateur_spec.rb'
- 'spec/jobs/structure/assigne_job_spec.rb'
- 'spec/mailers/structure_spec.rb'
- 'spec/models/donnees_sociodemographique_spec.rb'
- 'spec/models/restitution/objet_trouves_spec.rb'
- 'spec/models/restitution/securite/nombre_dangers_bien_identifies_avant_aide_1_spec.rb'

# Offense count: 102
RSpec/StubbedMock:
Enabled: false

# Offense count: 12
RSpec/SubjectDeclaration:
Exclude:
- 'spec/models/restitution/competences_transversales/interpreteur_spec.rb'
- 'spec/models/restitution/illettrisme/interpreteur_niveau1_spec.rb'
- 'spec/models/restitution/illettrisme/interpreteur_scores_spec.rb'
- 'spec/models/restitution/illettrisme/synthetiseur_spec.rb'
- 'spec/models/restitution/standardisateur_fige_spec.rb'
- 'spec/models/restitution/standardisateur_glissant_spec.rb'

# Offense count: 1
# Configuration parameters: EnforcedStyle, AllowedPatterns.
# SupportedStyles: snake_case, camelCase
RSpec/VariableName:
Exclude:
- 'spec/requests/evaluations_spec.rb'

# Offense count: 74
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
RSpec/VerifiedDoubles:
Exclude:
- 'spec/controllers/structures_controller_spec.rb'
- 'spec/features/admin/evaluation_spec.rb'
- 'spec/helpers/application_helper_spec.rb'
- 'spec/models/campagne_spec.rb'
- 'spec/models/restitution/completude_spec.rb'
- 'spec/models/restitution/globale_spec.rb'
- 'spec/models/restitution/scores_niveau2_spec.rb'
- 'spec/models/situation_configuration_spec.rb'
- 'spec/tasks/ajoute_evenements_termines_spec.rb'
- 'spec/tasks/recalcule_metriques_spec.rb'
6 changes: 3 additions & 3 deletions spec/controllers/api/evaluations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
it 'ajoute bien une evaluation à la création' do
expect do
post :create, params: evaluation_params
end.to change { Evaluation.count }.by(1)
end.to change(Evaluation, :count).by(1)
end

it "lorsqu'on crée une evaluation, on crée un bénéficiaire" do
expect do
post :create, params: evaluation_params
end.to change { Beneficiaire.count }.by(1)
end.to change(Beneficiaire, :count).by(1)
end
end

Expand All @@ -39,7 +39,7 @@
evaluation = create :evaluation
expect do
put :update, params: { id: evaluation.id, nom: nom }
end.to change { Beneficiaire.count }.by(0)
end.not_to(change(Beneficiaire, :count))
expect(response).to have_http_status(:success)
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/controllers/eva/devise/session_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
describe Eva::Devise::SessionsController, type: :controller do
let!(:compte) { create :compte_admin }
let!(:campagne) { create :campagne, compte: compte, code: 'CODECAMPAGNE' }

describe 'POST connexion_espace_jeu' do
context 'quand on passe un code campagne valide' do
it "redirige vers l'espace jeu" do
Expand Down
3 changes: 2 additions & 1 deletion spec/features/admin/campagne_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
context 'quelque soit le rôle' do
let!(:evaluation) { create :evaluation, campagne: campagne }
let!(:evaluation_conseiller) { create :evaluation, campagne: ma_campagne }

before { visit admin_campagnes_path }

it "affiche le nombre d'évaluation par campagne" do
Expand Down Expand Up @@ -207,7 +208,7 @@
end

it "soft_delete la campagne mais garde l'association avec l'evaluation" do
expect(campagne.deleted_at).not_to be nil
expect(campagne.deleted_at).not_to be_nil
expect(evaluation.campagne_id).to eq campagne.id
end
end
Expand Down
4 changes: 3 additions & 1 deletion spec/features/admin/compte_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

describe 'index' do
let(:compte_connecte) { compte_superadmin }

before { visit admin_comptes_path }

it { expect(page).to have_content 'moi@structure' }
Expand Down Expand Up @@ -311,6 +312,7 @@
end

it { expect(page).to have_content(/nouvel-email@exemple.fr/) }

it do
expect(page).to have_content(/Consultez votre boîte de réception,/)
end
Expand All @@ -336,7 +338,7 @@
context "quand je suis sur la show d'un autre compte" do
before { visit admin_compte_path(collegue) }

it { expect(page).to_not have_content(/Confirmez votre adresse email/) }
it { expect(page).not_to have_content(/Confirmez votre adresse email/) }
end

context "quand l'email du compte d'un collègue a été modifié" do
Expand Down
5 changes: 2 additions & 3 deletions spec/features/admin/dashboard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
it "affiche l'étape valider son email" do
visit admin_path
expect(compte.confirmed?).to be false
expect(compte.unconfirmed_email).to be nil
expect(compte.unconfirmed_email).to be_nil
expect(page).not_to have_content('Testez votre campagne')
expect(page).to have_content('Confirmez votre adresse email')
expect(page).not_to have_content('Testez votre campagne')
Expand Down Expand Up @@ -157,10 +157,9 @@
before do
compte.update(mode_tutoriel: false)
compte.validation_en_attente!
visit admin_path
end

before { visit admin_path }

it do
expect(page).to have_content("Elle va bientôt vous permettre d'utiliser eva")
infos_support =
Expand Down
12 changes: 5 additions & 7 deletions spec/features/admin/evaluation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,9 @@

before do
competences = [[Competence::ORGANISATION_METHODE, Competence::NIVEAU_4]]
allow(restitution_globale).to receive(:niveaux_competences).and_return(competences)
interpretations = [[Competence::ORGANISATION_METHODE, 4.0]]
allow(restitution_globale).to receive(:interpretations_competences_transversales)
.and_return(interpretations)
allow(restitution_globale).to receive(:structure).and_return('structure')
allow(restitution_globale).to receive_messages(niveaux_competences: competences,
interpretations_competences_transversales: interpretations, structure: 'structure')
allow(restitution_globale).to receive(:synthese)
allow(restitution_globale).to receive(:synthese_pre_positionnement)
allow(restitution_globale).to receive(:synthese_positionnement)
Expand Down Expand Up @@ -305,7 +303,7 @@

it do
within('#action_items_sidebar_section') { click_on 'Supprimer' }
expect(evaluation.reload.deleted?).to eq true
expect(evaluation.reload.deleted?).to be true
expect(page.current_url).to eql(admin_campagne_url(ma_campagne))
end
end
Expand All @@ -324,7 +322,7 @@
find('a.lien-supprimer').click
end
expect(page).not_to have_content(mon_collegue.email)
expect(evaluation.reload.responsable_suivi).to eq nil
expect(evaluation.reload.responsable_suivi).to be_nil
end
end

Expand All @@ -341,7 +339,7 @@
find('a.lien-supprimer').click
end
expect(page).not_to have_content(mon_collegue.email)
expect(evaluation.reload.responsable_suivi).to eq nil
expect(evaluation.reload.responsable_suivi).to be_nil
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/parcours_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
end

it do
expect { click_on 'Créer' }.to(change { ParcoursType.count })
expect { click_on 'Créer' }.to(change(ParcoursType, :count))
expect(ParcoursType.last.description).to eq('Ma description')
end
end
Expand Down
Loading

0 comments on commit 12db9e5

Please sign in to comment.