|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +module DeviseTestHelper |
| 4 | + def devise_test |
| 5 | + gemfile_file = content('Gemfile') |
| 6 | + expect(gemfile_file).to match(/^gem 'devise'/) |
| 7 | + |
| 8 | + devise_initializers_test |
| 9 | + devise_route_file_test |
| 10 | + devise_model_file_test |
| 11 | + file_control_test |
| 12 | + end |
| 13 | + |
| 14 | + private |
| 15 | + |
| 16 | + def devise_initializers_test |
| 17 | + initializers_devise = content('config/initializers/devise.rb') |
| 18 | + expect(initializers_devise).to match('mailer') |
| 19 | + expect(initializers_devise).to match('mailer_sender') |
| 20 | + |
| 21 | + filter_parameter_logging = content('config/initializers/filter_parameter_logging.rb') |
| 22 | + expect(filter_parameter_logging).to match(':password') |
| 23 | + expect(filter_parameter_logging).to match(':password_confirmation') |
| 24 | + end |
| 25 | + |
| 26 | + def devise_route_file_test |
| 27 | + devise_route = content('config/routes.rb') |
| 28 | + expect(devise_route).to match('devise_for :users') |
| 29 | + end |
| 30 | + |
| 31 | + def devise_model_file_test # rubocop:disable Metrics/AbcSize |
| 32 | + devise_model_file = content('app/models/user.rb') |
| 33 | + expect(devise_model_file).to match(':database_authenticatable') |
| 34 | + expect(devise_model_file).to match(':registerable') |
| 35 | + expect(devise_model_file).to match(':recoverable') |
| 36 | + expect(devise_model_file).to match(':rememberable') |
| 37 | + expect(devise_model_file).to match(':trackable') |
| 38 | + expect(devise_model_file).to match(':validatable') |
| 39 | + end |
| 40 | + |
| 41 | + def file_control_test # rubocop:disable Metrics/AbcSize |
| 42 | + expect(File).to exist(file_project_path('app/views/devise/confirmations')) |
| 43 | + expect(File).to exist(file_project_path('app/views/devise/mailer')) |
| 44 | + expect(File).to exist(file_project_path('app/views/devise/passwords')) |
| 45 | + expect(File).to exist(file_project_path('app/views/devise/registrations')) |
| 46 | + expect(File).to exist(file_project_path('app/views/devise/sessions')) |
| 47 | + expect(File).to exist(file_project_path('app/views/devise/shared')) |
| 48 | + expect(File).to exist(file_project_path('app/views/devise/unlocks')) |
| 49 | + |
| 50 | + expect(File).not_to exist(file_project_path('config/locales/devise.en.yml')) |
| 51 | + end |
| 52 | +end |
0 commit comments