|
3 | 3 | require 'generators/graphql_devise/install_generator' |
4 | 4 |
|
5 | 5 | RSpec.describe GraphqlDevise::InstallGenerator, type: :generator do |
6 | | - destination File.expand_path('../../../../dummy', __dir__) |
| 6 | + destination File.expand_path('../../../../gqld_dummy', __dir__) |
7 | 7 |
|
8 | 8 | before do |
9 | 9 | prepare_destination |
|
18 | 18 | before { run_generator } |
19 | 19 |
|
20 | 20 | it 'creates and updated required files' do |
21 | | - assert_file 'config/routes.rb', /\s{2,}mount_graphql_devise_for 'User', at: 'auth'/ |
| 21 | + assert_file 'config/routes.rb', /^\s{2}mount_graphql_devise_for 'User', at: 'auth'/ |
22 | 22 | expect(routes_content).not_to match(dta_route) |
23 | 23 |
|
24 | 24 | assert_file 'config/initializers/devise.rb' |
25 | 25 | assert_file 'config/initializers/devise_token_auth.rb' |
| 26 | + assert_file 'config/locales/devise.en.yml' |
| 27 | + |
| 28 | + assert_migration 'db/migrate/devise_token_auth_create_users.rb' |
| 29 | + |
| 30 | + assert_file 'app/models/user.rb', /^\s{2}devise :.+include GraphqlDevise::Concerns::Model/m |
| 31 | + |
| 32 | + assert_file 'app/controllers/application_controller.rb', /^\s{2}include GraphqlDevise::Concerns::SetUserByToken/ |
26 | 33 | end |
27 | 34 | end |
28 | 35 |
|
29 | 36 | context 'when passing custom params to the generator' do |
30 | 37 | before { run_generator %w[Admin api] } |
31 | 38 |
|
32 | 39 | it 'creates and updated required files' do |
33 | | - assert_file 'config/routes.rb', /\s{2,}mount_graphql_devise_for 'Admin', at: 'api'/ |
| 40 | + assert_file 'config/routes.rb', /^\s{2}mount_graphql_devise_for 'Admin', at: 'api'/ |
34 | 41 | expect(routes_content).not_to match(dta_route) |
35 | 42 |
|
36 | 43 | assert_file 'config/initializers/devise.rb' |
37 | 44 | assert_file 'config/initializers/devise_token_auth.rb' |
| 45 | + assert_file 'config/locales/devise.en.yml' |
| 46 | + |
| 47 | + assert_migration 'db/migrate/devise_token_auth_create_admins.rb' |
| 48 | + |
| 49 | + assert_file 'app/models/admin.rb', /^\s{2}devise :.+include GraphqlDevise::Concerns::Model/m |
| 50 | + |
| 51 | + assert_file 'app/controllers/application_controller.rb', /^\s{2}include GraphqlDevise::Concerns::SetUserByToken/ |
38 | 52 | end |
39 | 53 | end |
40 | 54 |
|
41 | 55 | def create_rails_project |
42 | 56 | FileUtils.cd(File.join(destination_root, '..')) do |
43 | | - `rails new dummy -S -C --skip-action-mailbox --skip-action-text -T --skip-spring --skip-bundle --skip-keeps -G --skip-active-storage -J --skip-listen --skip-bootsnap` |
| 57 | + `rails new gqld_dummy -S -C --skip-action-mailbox --skip-action-text -T --skip-spring --skip-bundle --skip-keeps -G --skip-active-storage -J --skip-listen --skip-bootsnap` |
44 | 58 | end |
45 | 59 | end |
46 | 60 | end |
0 commit comments