graphql_devise 0.11.2 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,50 +3,61 @@ require 'rails_helper'
3
3
  require 'generators/graphql_devise/install_generator'
4
4
 
5
5
  RSpec.describe GraphqlDevise::InstallGenerator, type: :generator do
6
- destination File.expand_path('../../../tmp', __FILE__)
6
+ destination File.expand_path('../../../../gqld_dummy', __dir__)
7
+
8
+ let(:routes_path) { "#{destination_root}/config/routes.rb" }
9
+ let(:routes_content) { File.read(routes_path) }
10
+ let(:dta_route) { 'mount_devise_token_auth_for' }
11
+
12
+ after(:all) { FileUtils.rm_rf(destination_root) }
7
13
 
8
14
  before do
9
15
  prepare_destination
16
+ create_rails_project
17
+ run_generator(args)
10
18
  end
11
19
 
12
- let(:routes_path) { "#{destination_root}/config/routes.rb" }
13
- let(:routes_content) { File.read(routes_path) }
14
- let(:dta_route) { "mount_devise_token_auth_for 'User', at: 'auth'" }
15
-
16
- xcontext 'when the file exists' do
17
- before do
18
- create_file_with_content(
19
- routes_path,
20
- "Rails.application.routes.draw do\n#{dta_route}\nend"
21
- )
22
- end
20
+ context 'when passing no params to the generator' do
21
+ let(:args) { [] }
23
22
 
24
- context 'when passing no params to the generator' do
25
- before { run_generator }
23
+ it 'creates and updated required files' do
24
+ assert_file 'config/routes.rb', /^\s{2}mount_graphql_devise_for 'User', at: 'auth'/
25
+ expect(routes_content).not_to match(dta_route)
26
26
 
27
- it 'replaces dta route using the default values for class and path' do
28
- generator_added_route = / mount_graphql_devise_for 'User', at: 'auth'/
29
- expect(routes_content).to match(generator_added_route)
30
- expect(routes_content).not_to match(dta_route)
31
- end
32
- end
27
+ assert_file 'config/initializers/devise.rb'
28
+ assert_file 'config/initializers/devise_token_auth.rb', /^\s{2}#{Regexp.escape('config.change_headers_on_each_request = false')}/
29
+ assert_file 'config/locales/devise.en.yml'
33
30
 
34
- context 'when passing custom params to the generator' do
35
- before { run_generator %w[Admin api] }
31
+ assert_migration 'db/migrate/devise_token_auth_create_users.rb'
36
32
 
37
- it 'add the routes using the provided values for class and path and keeps dta route' do
38
- generator_added_route = / mount_graphql_devise_for 'Admin', at: 'api'/
39
- expect(routes_content).to match(generator_added_route)
40
- expect(routes_content).to match(dta_route)
41
- end
33
+ assert_file 'app/models/user.rb', /^\s{2}devise :.+include GraphqlDevise::Concerns::Model/m
34
+
35
+ assert_file 'app/controllers/application_controller.rb', /^\s{2}include GraphqlDevise::Concerns::SetUserByToken/
42
36
  end
43
37
  end
44
38
 
45
- xcontext 'when file does *NOT* exist' do
46
- before { run_generator }
39
+ context 'when passing custom params to the generator' do
40
+ let(:args) { %w[Admin api] }
41
+
42
+ it 'creates and updated required files' do
43
+ assert_file 'config/routes.rb', /^\s{2}mount_graphql_devise_for 'Admin', at: 'api'/
44
+ expect(routes_content).not_to match(dta_route)
45
+
46
+ assert_file 'config/initializers/devise.rb'
47
+ assert_file 'config/initializers/devise_token_auth.rb', /^\s{2}#{Regexp.escape('config.change_headers_on_each_request = false')}/
48
+ assert_file 'config/locales/devise.en.yml'
49
+
50
+ assert_migration 'db/migrate/devise_token_auth_create_admins.rb'
51
+
52
+ assert_file 'app/models/admin.rb', /^\s{2}devise :.+include GraphqlDevise::Concerns::Model/m
53
+
54
+ assert_file 'app/controllers/application_controller.rb', /^\s{2}include GraphqlDevise::Concerns::SetUserByToken/
55
+ end
56
+ end
47
57
 
48
- it 'does *NOT* create the file and throw no exception' do
49
- expect(File.exist?(routes_path)).to be_falsey
58
+ def create_rails_project
59
+ FileUtils.cd(File.join(destination_root, '..')) do
60
+ `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`
50
61
  end
51
62
  end
52
63
  end
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,7 @@ if ENV['CI'] && !ENV['SKIP_COVERALLS']
4
4
 
5
5
  SimpleCov.formatter = Coveralls::SimpleCov::Formatter
6
6
  SimpleCov.start 'rails' do
7
- add_filter ['spec', 'lib/generators']
7
+ add_filter ['spec']
8
8
  end
9
9
  end
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql_devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Celi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-05-07 00:00:00.000000000 Z
12
+ date: 2020-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise_token_auth
@@ -396,7 +396,6 @@ files:
396
396
  - spec/dummy/log/development.log
397
397
  - spec/dummy/log/test.log
398
398
  - spec/dummy/public/robots.txt
399
- - spec/dummy/tmp/development_secret.txt
400
399
  - spec/factories/admins.rb
401
400
  - spec/factories/guests.rb
402
401
  - spec/factories/users.rb
@@ -534,7 +533,6 @@ test_files:
534
533
  - spec/dummy/db/development.sqlite3
535
534
  - spec/dummy/log/test.log
536
535
  - spec/dummy/log/development.log
537
- - spec/dummy/tmp/development_secret.txt
538
536
  - spec/graphql_devise_spec.rb
539
537
  - spec/models/user_spec.rb
540
538
  - spec/requests/user_controller_spec.rb
@@ -1 +0,0 @@
1
- 55c87511d98be47eda90278d93df0f2b845abb95ec72a16d859cbe044c8851f2cacad02036cbe96fd9544454128894794dbabe633d03b07f90967741a6da612b