potassium 5.2.0 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +42 -0
  3. data/.editorconfig +3 -0
  4. data/.node-version +1 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +94 -0
  7. data/README.md +41 -47
  8. data/docs/DSL.md +5 -5
  9. data/lib/potassium/assets/.buildpacks +0 -1
  10. data/lib/potassium/assets/.circleci/config.yml.erb +102 -0
  11. data/lib/potassium/assets/.eslintrc.json +352 -0
  12. data/lib/potassium/assets/.github/pull_request_template.md +9 -0
  13. data/lib/potassium/assets/.pryrc +1 -1
  14. data/lib/potassium/assets/.rubocop.yml +515 -0
  15. data/lib/potassium/assets/.stylelintrc.json +46 -0
  16. data/lib/potassium/assets/Dockerfile.ci +1 -1
  17. data/lib/potassium/assets/Makefile.erb +35 -0
  18. data/lib/potassium/assets/Procfile +1 -0
  19. data/lib/potassium/assets/README.yml +60 -11
  20. data/lib/potassium/assets/active_admin/admin-component.vue +35 -0
  21. data/lib/potassium/assets/active_admin/admin_application.js +14 -0
  22. data/lib/potassium/assets/active_admin/init_activeadmin_vue.rb +10 -0
  23. data/lib/potassium/assets/app/graphql/graphql_controller.rb +55 -0
  24. data/lib/potassium/assets/app/graphql/mutations/login_mutation.rb +23 -0
  25. data/lib/potassium/assets/app/graphql/queries/base_query.rb +4 -0
  26. data/lib/potassium/assets/app/graphql/types/base/base_argument.rb +4 -0
  27. data/lib/potassium/assets/app/graphql/types/base/base_enum.rb +4 -0
  28. data/lib/potassium/assets/app/graphql/types/base/base_field.rb +5 -0
  29. data/lib/potassium/assets/app/graphql/types/base/base_input_object.rb +5 -0
  30. data/lib/potassium/assets/app/graphql/types/base/base_interface.rb +7 -0
  31. data/lib/potassium/assets/app/graphql/types/base/base_object.rb +5 -0
  32. data/lib/potassium/assets/app/graphql/types/base/base_scalar.rb +4 -0
  33. data/lib/potassium/assets/app/graphql/types/base/base_union.rb +4 -0
  34. data/lib/potassium/assets/app/graphql/types/mutation_type.rb +10 -0
  35. data/lib/potassium/assets/app/graphql/types/query_type.rb +13 -0
  36. data/lib/potassium/assets/app/javascript/app.spec.js +14 -0
  37. data/lib/potassium/assets/app/uploaders/base_uploader.rb +11 -0
  38. data/lib/potassium/assets/app/uploaders/image_uploader.rb +5 -0
  39. data/lib/potassium/assets/bin/cibuild.erb +24 -7
  40. data/lib/potassium/assets/bin/release +9 -0
  41. data/lib/potassium/assets/bin/setup.erb +3 -0
  42. data/lib/potassium/assets/config/database_mysql.yml.erb +5 -5
  43. data/lib/potassium/assets/config/database_postgresql.yml.erb +5 -5
  44. data/lib/potassium/assets/config/graphql_playground.rb +20 -0
  45. data/lib/potassium/assets/config/puma.rb +5 -1
  46. data/lib/potassium/assets/config/shrine.rb +36 -0
  47. data/lib/potassium/assets/docker-compose.ci.yml +2 -1
  48. data/lib/potassium/assets/docker-compose.yml +6 -0
  49. data/lib/potassium/assets/lib/tasks/auto_annotate_models.rake +34 -33
  50. data/lib/potassium/assets/package.json +4 -1
  51. data/lib/potassium/assets/redis.yml +1 -2
  52. data/lib/potassium/assets/sidekiq_scheduler.yml +1 -1
  53. data/lib/potassium/assets/testing/rails_helper.rb +4 -2
  54. data/lib/potassium/cli/commands/create.rb +12 -19
  55. data/lib/potassium/cli_options.rb +67 -24
  56. data/lib/potassium/helpers/docker-helpers.rb +14 -5
  57. data/lib/potassium/helpers/gem-helpers.rb +1 -1
  58. data/lib/potassium/helpers/template-helpers.rb +4 -0
  59. data/lib/potassium/newest_version_ensurer.rb +19 -36
  60. data/lib/potassium/node_version_ensurer.rb +30 -0
  61. data/lib/potassium/recipes/admin.rb +3 -3
  62. data/lib/potassium/recipes/annotate.rb +1 -1
  63. data/lib/potassium/recipes/api.rb +93 -21
  64. data/lib/potassium/recipes/background_processor.rb +38 -2
  65. data/lib/potassium/recipes/ci.rb +8 -6
  66. data/lib/potassium/recipes/data_migrate.rb +44 -0
  67. data/lib/potassium/recipes/database.rb +6 -2
  68. data/lib/potassium/recipes/database_container.rb +90 -0
  69. data/lib/potassium/recipes/draper.rb +1 -10
  70. data/lib/potassium/recipes/file_storage.rb +66 -0
  71. data/lib/potassium/recipes/front_end.rb +219 -9
  72. data/lib/potassium/recipes/github.rb +93 -15
  73. data/lib/potassium/recipes/heroku.rb +2 -1
  74. data/lib/potassium/recipes/listen.rb +7 -0
  75. data/lib/potassium/recipes/mailer.rb +14 -4
  76. data/lib/potassium/recipes/node.rb +21 -0
  77. data/lib/potassium/recipes/puma.rb +0 -3
  78. data/lib/potassium/recipes/rack_cors.rb +18 -15
  79. data/lib/potassium/recipes/rails.rb +6 -0
  80. data/lib/potassium/recipes/schedule.rb +1 -1
  81. data/lib/potassium/recipes/style.rb +21 -3
  82. data/lib/potassium/recipes/vue_admin.rb +124 -0
  83. data/lib/potassium/templates/application.rb +10 -9
  84. data/lib/potassium/version.rb +7 -4
  85. data/potassium.gemspec +9 -6
  86. data/spec/features/api_spec.rb +25 -0
  87. data/spec/features/background_processor_spec.rb +12 -1
  88. data/spec/features/data_migrate_spec.rb +14 -0
  89. data/spec/features/database_container_spec.rb +35 -0
  90. data/spec/features/draper_spec.rb +1 -6
  91. data/spec/features/file_storage_spec.rb +75 -0
  92. data/spec/features/front_end_spec.rb +88 -0
  93. data/spec/features/github_spec.rb +53 -8
  94. data/spec/features/graphql_spec.rb +71 -0
  95. data/spec/features/heroku_spec.rb +8 -5
  96. data/spec/features/mailer_spec.rb +42 -0
  97. data/spec/features/new_project_spec.rb +6 -14
  98. data/spec/features/node_spec.rb +28 -0
  99. data/spec/features/power_types_spec.rb +5 -16
  100. data/spec/features/vue_admin_spec.rb +47 -0
  101. data/spec/spec_helper.rb +5 -0
  102. data/spec/support/fake_octokit.rb +31 -0
  103. data/spec/support/potassium_test_helpers.rb +26 -8
  104. metadata +126 -45
  105. data/circle.yml +0 -12
  106. data/lib/potassium/assets/.circleci/config.yml +0 -20
  107. data/lib/potassium/assets/active_admin/active_admin.js.coffee +0 -4
  108. data/lib/potassium/assets/active_admin/init_activeadmin_angular.rb +0 -8
  109. data/lib/potassium/assets/api/api_error_concern.rb +0 -32
  110. data/lib/potassium/assets/api/base_controller.rb +0 -9
  111. data/lib/potassium/assets/api/draper_responder.rb +0 -62
  112. data/lib/potassium/assets/api/responder.rb +0 -41
  113. data/lib/potassium/assets/aws.rb +0 -1
  114. data/lib/potassium/assets/testing/paperclip.rb +0 -59
  115. data/lib/potassium/recipes/active_storage.rb +0 -40
  116. data/lib/potassium/recipes/angular_admin.rb +0 -56
  117. data/lib/potassium/recipes/aws_sdk.rb +0 -7
  118. data/lib/potassium/recipes/paperclip.rb +0 -47
  119. data/spec/features/active_storage_spec.rb +0 -30
  120. data/spec/features/front_end.rb +0 -30
@@ -1,4 +1,5 @@
1
1
  set :app_name, app_name
2
+ set :node_version, node_version
2
3
  set :titleized_app_name, get(:app_name).titleize
3
4
  set :underscorized_app_name, get(:app_name).underscore
4
5
  set :dasherized_app_name, get(:app_name).dasherize
@@ -9,7 +10,6 @@ end
9
10
 
10
11
  run_action(:cleaning) do
11
12
  clean_gemfile
12
- gather_gem("spring")
13
13
  end
14
14
 
15
15
  run_action(:add_utils) do
@@ -21,7 +21,7 @@ run_action(:asking) do
21
21
  ask :devise
22
22
  ask :admin
23
23
  ask :front_end
24
- ask :angular_admin
24
+ ask :vue_admin
25
25
  ask :mailer
26
26
  ask :background_processor
27
27
  ask :schedule
@@ -30,8 +30,7 @@ run_action(:asking) do
30
30
  ask :i18n
31
31
  ask :api
32
32
  ask :draper
33
- ask :active_storage
34
- ask :paperclip
33
+ ask :file_storage
35
34
  ask :heroku
36
35
  ask :github
37
36
  end
@@ -43,13 +42,16 @@ run_action(:recipe_loading) do
43
42
  create :ci
44
43
  create :style
45
44
  create :puma
45
+ create :env
46
+ create :database_container
46
47
  create :database
47
48
  create :annotate
49
+ create :data_migrate
50
+ create :listen
51
+ create :node
48
52
  create :ruby
49
- create :env
50
53
  create :yarn
51
54
  create :editorconfig
52
- create :aws_sdk
53
55
  create :mailer
54
56
  create :background_processor
55
57
  create :schedule
@@ -58,7 +60,7 @@ run_action(:recipe_loading) do
58
60
  create :better_errors
59
61
  create :devise
60
62
  create :admin
61
- create :angular_admin
63
+ create :vue_admin
62
64
  create :seeds
63
65
  create :error_reporting
64
66
  create :pundit
@@ -68,8 +70,7 @@ run_action(:recipe_loading) do
68
70
  create :draper
69
71
  create :power_types
70
72
  create :rack_cors
71
- create :active_storage
72
- create :paperclip
73
+ create :file_storage
73
74
  create :tzinfo
74
75
  create :script
75
76
  create :github
@@ -1,6 +1,9 @@
1
1
  module Potassium
2
- VERSION = "5.2.0"
3
- RUBY_VERSION = "2.5.1"
4
- RAILS_VERSION = "~> 5.2.1"
5
- RUBOCOP_VERSION = "~> 0.49.1"
2
+ VERSION = "6.1.0"
3
+ RUBY_VERSION = "2.7.0"
4
+ RAILS_VERSION = "~> 6.0.2"
5
+ RUBOCOP_VERSION = "~> 0.65.0"
6
+ POSTGRES_VERSION = "11.3"
7
+ MYSQL_VERSION = "5.7"
8
+ NODE_VERSION = "12"
6
9
  end
@@ -18,15 +18,18 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec", "~> 3.4.0"
21
+ spec.add_development_dependency "bundler", "~> 2.0"
24
22
  spec.add_development_dependency "pry", "~> 0.10.3"
23
+ spec.add_development_dependency "rake", "~> 13.0"
24
+ spec.add_development_dependency "rspec", "~> 3.4.0"
25
+ spec.add_development_dependency "rspec_junit_formatter"
25
26
  spec.add_development_dependency "rubocop", Potassium::RUBOCOP_VERSION
26
- spec.add_runtime_dependency "rails", Potassium::RAILS_VERSION
27
+ spec.add_development_dependency "rubocop-rspec"
28
+ spec.add_runtime_dependency "gems", "~> 0.8"
27
29
  spec.add_runtime_dependency "gli", "~> 2.12.2"
28
30
  spec.add_runtime_dependency "inquirer", "~> 0.2"
29
- spec.add_runtime_dependency "gems", "~> 0.8"
30
- spec.add_runtime_dependency "semantic", "~> 1.4"
31
31
  spec.add_runtime_dependency "levenshtein", "~> 0.2"
32
+ spec.add_runtime_dependency "octokit", "~> 4.18"
33
+ spec.add_runtime_dependency "rails", Potassium::RAILS_VERSION
34
+ spec.add_runtime_dependency "semantic", "~> 1.4"
32
35
  end
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Api" do
4
+ before :all do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ create_dummy_project("api" => :rest)
8
+ end
9
+
10
+ it "adds power_api related gems to Gemfile" do
11
+ gemfile_content = IO.read("#{project_path}/Gemfile")
12
+ expect(gemfile_content).to include("gem 'power_api'")
13
+ expect(gemfile_content).to include("gem 'rswag-specs'")
14
+ end
15
+
16
+ it "adds the power_api brief to README file" do
17
+ readme = IO.read("#{project_path}/README.md")
18
+ expect(readme).to include("Power API")
19
+ end
20
+
21
+ it "installs power_api" do
22
+ content = IO.read("#{project_path}/app/controllers/api/base_controller.rb")
23
+ expect(content).to include("Api::BaseController < PowerApi::BaseController")
24
+ end
25
+ end
@@ -1,4 +1,5 @@
1
1
  require "spec_helper"
2
+ require 'yaml'
2
3
 
3
4
  RSpec.describe "BackgroundProcessor" do
4
5
  context "working with sidekiq" do
@@ -41,6 +42,9 @@ RSpec.describe "BackgroundProcessor" do
41
42
  it "adds ENV vars" do
42
43
  content = IO.read("#{project_path}/.env.development")
43
44
  expect(content).to include("DB_POOL=25")
45
+ expect(content).to include('REDIS_HOST=127.0.0.1')
46
+ expect(content).to include('REDIS_PORT=$(make services-port SERVICE=redis PORT=6379)')
47
+ expect(content).to include('REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT}/1')
44
48
  end
45
49
 
46
50
  it "adds sidekiq.rb file" do
@@ -55,12 +59,19 @@ RSpec.describe "BackgroundProcessor" do
55
59
 
56
60
  it "adds redis.yml file" do
57
61
  content = IO.read("#{project_path}/config/redis.yml")
58
- expect(content).to include("REDIS_HOST")
62
+ expect(content).to include("REDIS_URL")
59
63
  end
60
64
 
61
65
  it "mounts sidekiq app" do
62
66
  content = IO.read("#{project_path}/config/routes.rb")
63
67
  expect(content).to include("mount Sidekiq::Web => '/queue'")
64
68
  end
69
+
70
+ it 'adds redis to docker-compose' do
71
+ compose_file = IO.read("#{project_path}/docker-compose.yml")
72
+ compose_content = YAML.safe_load(compose_file, symbolize_names: true)
73
+
74
+ expect(compose_content[:services]).to include(:redis)
75
+ end
65
76
  end
66
77
  end
@@ -0,0 +1,14 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe 'DataMigrate' do
4
+ let(:gemfile) { IO.read("#{project_path}/Gemfile") }
5
+ let(:annotate_task) { IO.read("#{project_path}/lib/tasks/auto_annotate_models.rake") }
6
+
7
+ before(:all) do
8
+ remove_project_directory
9
+ create_dummy_project
10
+ end
11
+
12
+ it { expect(gemfile).to include("data_migrate") }
13
+ it { expect(annotate_task).to include("data_migrate_tasks") }
14
+ end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+ require "yaml"
3
+
4
+ RSpec.describe "DatabaseContainer" do
5
+ before(:all) do
6
+ drop_dummy_database
7
+ end
8
+
9
+ before do
10
+ remove_project_directory
11
+ create_dummy_project("database" => database)
12
+ end
13
+
14
+ [:postgresql, :mysql].each do |db_type|
15
+ context "when database is #{db_type}" do
16
+ let!(:database) { db_type }
17
+
18
+ it "creates a #{db_type} database container" do
19
+ env_file = IO.read("#{project_path}/.env.development")
20
+ compose_file = IO.read("#{project_path}/docker-compose.yml")
21
+ compose_content = YAML.safe_load(compose_file, symbolize_names: true)
22
+ setup_file = IO.read("#{project_path}/bin/setup")
23
+
24
+ service_name = compose_content[:services].keys.first
25
+ db_port = compose_content[:services][service_name][:ports].first
26
+
27
+ expect(env_file)
28
+ .to include("DB_PORT=$(make services-port SERVICE=#{service_name} PORT=#{db_port})")
29
+ expect(env_file).to include("DB_HOST=127.0.0.1")
30
+ expect(File.exist?("#{project_path}/Makefile")).to be true
31
+ expect(setup_file).to include("docker-compose up -d")
32
+ end
33
+ end
34
+ end
35
+ end
@@ -4,7 +4,7 @@ RSpec.describe "Draper" do
4
4
  before :all do
5
5
  drop_dummy_database
6
6
  remove_project_directory
7
- create_dummy_project("draper" => true, "api" => true)
7
+ create_dummy_project("draper" => true)
8
8
  end
9
9
 
10
10
  it "adds the Draper gem to Gemfile" do
@@ -17,11 +17,6 @@ RSpec.describe "Draper" do
17
17
  expect(readme).to include("Draper")
18
18
  end
19
19
 
20
- it "adds api responder to work with draper" do
21
- responder_content = IO.read("#{project_path}/app/responders/api_responder.rb")
22
- expect(responder_content).to include("decorated_resource")
23
- end
24
-
25
20
  it "adds decorators directory" do
26
21
  content = IO.read("#{project_path}/app/decorators/.keep")
27
22
  expect(content).to be_empty
@@ -0,0 +1,75 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "File Storage" do
4
+ context "when selecting active_storage" do
5
+ before :all do
6
+ drop_dummy_database
7
+ remove_project_directory
8
+ create_dummy_project(storage: :active_storage)
9
+ end
10
+
11
+ it "adds the aws-sdk-s3 gem to Gemfile" do
12
+ gemfile_content = IO.read("#{project_path}/Gemfile")
13
+ expect(gemfile_content).to include("gem 'aws-sdk-s3'")
14
+ end
15
+
16
+ it "customizes config file" do
17
+ content = IO.read("#{project_path}/config/storage.yml")
18
+ expect(content).to include("bucket: <%= ENV['S3_BUCKET'] %>")
19
+ end
20
+
21
+ it "adds brief to README file" do
22
+ content = IO.read("#{project_path}/README.md")
23
+ expect(content).to include("Active Storage")
24
+ end
25
+
26
+ it "uses amazon on production env" do
27
+ content = IO.read("#{project_path}/config/environments/production.rb")
28
+ expect(content).to include("config.active_storage.service = :amazon")
29
+ end
30
+
31
+ it "adds S3 bucket ENV vars" do
32
+ content = IO.read("#{project_path}/.env.development")
33
+ expect(content).to include("S3_BUCKET=")
34
+ end
35
+ end
36
+
37
+ context "when selecting shrine" do
38
+ before :all do
39
+ drop_dummy_database
40
+ remove_project_directory
41
+ create_dummy_project(storage: :shrine)
42
+ end
43
+
44
+ it "adds the aws-sdk-s3, shrine and marcel gems to Gemfile" do
45
+ gemfile_content = IO.read("#{project_path}/Gemfile")
46
+ expect(gemfile_content).to include("gem 'aws-sdk-s3'")
47
+ expect(gemfile_content).to include("gem 'shrine'")
48
+ expect(gemfile_content).to include("gem 'marcel'")
49
+ end
50
+
51
+ it "adds brief to README file" do
52
+ content = IO.read("#{project_path}/README.md")
53
+ expect(content).to include("Shrine")
54
+ end
55
+
56
+ it "adds shrine initializer" do
57
+ expect(File.exist?("#{project_path}/config/initializers/shrine.rb")).to be true
58
+ end
59
+
60
+ it "adds base_uploader and image_uploader" do
61
+ expect(File.exist?("#{project_path}/app/uploaders/base_uploader.rb")).to be true
62
+ expect(File.exist?("#{project_path}/app/uploaders/image_uploader.rb")).to be true
63
+ end
64
+
65
+ it "adds S3 bucket ENV vars" do
66
+ content = IO.read("#{project_path}/.env.development")
67
+ expect(content).to include("S3_BUCKET=")
68
+ end
69
+
70
+ it "adds filestorage path to gitignore" do
71
+ content = IO.read("#{project_path}/.gitignore")
72
+ expect(content).to include("/public/uploads")
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,88 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Front end" do
4
+ before :all do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ end
8
+
9
+ let(:application_css_path) { "#{project_path}/app/javascript/css/application.css" }
10
+ let(:gemfile) { IO.read("#{project_path}/Gemfile") }
11
+ let(:node_modules_file) { IO.read("#{project_path}/package.json") }
12
+ let(:application_js_file) { IO.read("#{project_path}/app/javascript/packs/application.js") }
13
+ let(:layout_file) { IO.read("#{project_path}/app/views/layouts/application.html.erb") }
14
+ let(:application_css_file) { IO.read(application_css_path) }
15
+ let(:tailwind_config_file) { IO.read("#{project_path}/tailwind.config.js") }
16
+ let(:rails_css_file) { IO.read("#{project_path}/app/assets/stylesheets/application.css") }
17
+
18
+ it "creates a project without a front end framework" do
19
+ remove_project_directory
20
+ create_dummy_project("front_end" => "None")
21
+ expect(gemfile).to include('webpacker')
22
+ expect(File).not_to exist(application_css_path)
23
+ end
24
+
25
+ context "with vue" do
26
+ before(:all) do
27
+ remove_project_directory
28
+ create_dummy_project("front_end" => "vue")
29
+ end
30
+
31
+ it "creates a project with vue in compiler mode as frontend framework" do
32
+ expect(gemfile).to include('webpacker')
33
+ expect(node_modules_file).to include("\"vue\"")
34
+ expect(application_js_file).to include('vue/dist/vue.esm')
35
+ expect(application_js_file).to include("el: '#vue-app'")
36
+ expect(layout_file).to include('id="vue-app"')
37
+ end
38
+
39
+ it "creates a project with only one js pack tag" do
40
+ expect(layout_file.scan("javascript_pack_tag").length).to eq(1)
41
+ end
42
+
43
+ it "creates a vue project with client css" do
44
+ expect(application_js_file).to include("import '../css/application.css';")
45
+ expect(layout_file).to include("<%= stylesheet_pack_tag 'application' %>")
46
+ expect(rails_css_file).not_to include('*= require_tree', '*= require_self')
47
+ end
48
+
49
+ it "creates a vue project with tailwindcss" do
50
+ expect(node_modules_file).to include("\"tailwindcss\"")
51
+ expect(application_css_file).to include(
52
+ "@import 'tailwindcss/base';",
53
+ "@import 'tailwindcss/components';"
54
+ )
55
+ expect(tailwind_config_file).to include('module.exports')
56
+ end
57
+
58
+ context "with graphql" do
59
+ before(:all) do
60
+ remove_project_directory
61
+ create_dummy_project("front_end" => "vue", "api" => "graphql")
62
+ end
63
+
64
+ it "creates a vue project with apollo" do
65
+ expect(node_modules_file).to include("\"vue-apollo\"")
66
+ expect(application_js_file).to include("import { ApolloClient } from 'apollo-client';")
67
+ expect(application_js_file).to include("Vue.use(VueApollo)")
68
+ expect(application_js_file).to include("apolloProvider,")
69
+ end
70
+ end
71
+ end
72
+
73
+ context "with angular" do
74
+ before(:all) do
75
+ remove_project_directory
76
+ create_dummy_project("front_end" => "angular")
77
+ end
78
+
79
+ it "creates a project without vue as front end framework" do
80
+ expect(gemfile).to include('webpacker')
81
+ expect(node_modules_file).to include("\"@angular/core\"")
82
+ end
83
+
84
+ it "creates application_js_file for tailwind without vue" do
85
+ expect(application_js_file).to include("import '../css/application.css';")
86
+ end
87
+ end
88
+ end
@@ -1,22 +1,67 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe "GitHub" do
4
+ let(:org_name) { "platanus" }
5
+ let(:repo_name) { PotassiumTestHelpers::APP_NAME.dasherize }
6
+ let(:access_token) { "1234" }
7
+ let(:pr_template_file) { IO.read("#{project_path}/.github/pull_request_template.md") }
8
+
4
9
  before do
5
10
  drop_dummy_database
6
11
  remove_project_directory
7
12
  end
8
13
 
9
- it "create a the github repository" do
10
- create_dummy_project("github" => true)
11
- app_name = PotassiumTestHelpers::APP_NAME.dasherize
14
+ it "creates the github repository" do
15
+ create_dummy_project(
16
+ "github" => true,
17
+ "github_private" => false,
18
+ "github_has_org" => false,
19
+ "github_name" => repo_name,
20
+ "github_access_token" => access_token
21
+ )
22
+
23
+ expect(FakeOctokit).to have_created_repo(repo_name)
24
+ expect(pr_template_file).to include('Contexto')
25
+ end
26
+
27
+ it "creates the private github repository" do
28
+ create_dummy_project(
29
+ "github" => true,
30
+ "github_private" => true,
31
+ "github_has_org" => false,
32
+ "github_name" => repo_name,
33
+ "github_access_token" => access_token
34
+ )
35
+
36
+ expect(FakeOctokit).to have_created_private_repo(repo_name)
37
+ expect(pr_template_file).to include('Contexto')
38
+ end
39
+
40
+ it "creates the github repository for the organization" do
41
+ create_dummy_project(
42
+ "github" => true,
43
+ "github_private" => false,
44
+ "github_has_org" => true,
45
+ "github_org" => org_name,
46
+ "github_name" => repo_name,
47
+ "github_access_token" => access_token
48
+ )
12
49
 
13
- expect(FakeGithub).to have_created_repo("platanus/#{app_name}")
50
+ expect(FakeOctokit).to have_created_repo_for_org(repo_name, org_name)
51
+ expect(pr_template_file).to include('Contexto')
14
52
  end
15
53
 
16
- it "create a the github private repository" do
17
- create_dummy_project("github" => true, "github-private" => true)
18
- app_name = PotassiumTestHelpers::APP_NAME.dasherize
54
+ it "creates the private github repository for the organization" do
55
+ create_dummy_project(
56
+ "github" => true,
57
+ "github_private" => true,
58
+ "github_has_org" => true,
59
+ "github_org" => org_name,
60
+ "github_name" => repo_name,
61
+ "github_access_token" => access_token
62
+ )
19
63
 
20
- expect(FakeGithub).to have_created_private_repo("platanus/#{app_name}")
64
+ expect(FakeOctokit).to have_created_private_repo_for_org(repo_name, org_name)
65
+ expect(pr_template_file).to include('Contexto')
21
66
  end
22
67
  end