code42template 2.0.0

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.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +11 -0
  5. data/Gemfile +3 -0
  6. data/NEWS.md +56 -0
  7. data/README.md +280 -0
  8. data/Rakefile +8 -0
  9. data/bin/code42template +24 -0
  10. data/bin/rake +16 -0
  11. data/bin/rspec +16 -0
  12. data/bin/setup +13 -0
  13. data/code42template.gemspec +30 -0
  14. data/lib/code42template/actions.rb +28 -0
  15. data/lib/code42template/adapters/heroku.rb +174 -0
  16. data/lib/code42template/app_builder.rb +251 -0
  17. data/lib/code42template/generators/app_generator.rb +208 -0
  18. data/lib/code42template/version.rb +9 -0
  19. data/lib/code42template.rb +5 -0
  20. data/spec/adapters/heroku_spec.rb +56 -0
  21. data/spec/code42template.rb +58 -0
  22. data/spec/fakes/bin/heroku +5 -0
  23. data/spec/fakes/bin/hub +5 -0
  24. data/spec/features/heroku_spec.rb +83 -0
  25. data/spec/features/new_project_spec.rb +186 -0
  26. data/spec/fixtures/feature_smoke_test.rb +15 -0
  27. data/spec/fixtures/home_controller.rb +4 -0
  28. data/spec/fixtures/index.html.erb +1 -0
  29. data/spec/fixtures/routes.rb +3 -0
  30. data/spec/fixtures/smoke_test.rb +10 -0
  31. data/spec/spec_helper.rb +14 -0
  32. data/spec/support/code42template.rb +83 -0
  33. data/spec/support/fake_heroku.rb +83 -0
  34. data/templates/Gemfile.erb +42 -0
  35. data/templates/Procfile +3 -0
  36. data/templates/README.md.erb +10 -0
  37. data/templates/active_job.rb +1 -0
  38. data/templates/application.js +1 -0
  39. data/templates/bin_deploy +12 -0
  40. data/templates/bin_setup +21 -0
  41. data/templates/bin_setup_review_app.erb +19 -0
  42. data/templates/code42_gitignore +16 -0
  43. data/templates/config_locales_pt-BR.yml.erb +17 -0
  44. data/templates/dotfiles/.babelrc +5 -0
  45. data/templates/dotfiles/.codeclimate.yml +3 -0
  46. data/templates/dotfiles/.env +8 -0
  47. data/templates/dotfiles/.rspec +2 -0
  48. data/templates/dotfiles/.rubocop.yml +20 -0
  49. data/templates/feature_helper.rb.erb +5 -0
  50. data/templates/health.rake +22 -0
  51. data/templates/karma.conf.js +48 -0
  52. data/templates/mocha-webpack.opts +4 -0
  53. data/templates/package.json +39 -0
  54. data/templates/postgresql_database.yml.erb +22 -0
  55. data/templates/puma.rb +28 -0
  56. data/templates/rails_helper.rb +59 -0
  57. data/templates/secrets.yml +14 -0
  58. data/templates/setup +32 -0
  59. data/templates/sidekiq.yml +7 -0
  60. data/templates/spec/javascripts/.gitkeep +0 -0
  61. data/templates/spec/javascripts/index.browser.js +5 -0
  62. data/templates/spec/javascripts/index.integration.js +5 -0
  63. data/templates/spec/javascripts/integration/smoke.spec.js +7 -0
  64. data/templates/spec/javascripts/unit/smoke.spec.js +7 -0
  65. data/templates/spec_helper.rb +15 -0
  66. data/templates/travis.yml.erb +12 -0
  67. data/templates/webpack.config.js +68 -0
  68. data/templates/webpack.config.test.browser.js +17 -0
  69. data/templates/webpack.config.test.js +5 -0
  70. data/templates/webpack.rake +26 -0
  71. metadata +158 -0
@@ -0,0 +1,251 @@
1
+ require "forwardable"
2
+
3
+ module Code42Template
4
+ class AppBuilder < Rails::AppBuilder
5
+ include Code42Template::Actions
6
+ extend Forwardable
7
+
8
+ def_delegators(
9
+ :heroku_adapter,
10
+ :create_heroku_apps,
11
+ :create_deploy_script,
12
+ :update_readme_with_deploy,
13
+ :create_heroku_pipeline,
14
+ :create_production_heroku_app,
15
+ :create_staging_heroku_app,
16
+ :create_review_apps_setup_script,
17
+ :configure_heroku_buildpacks,
18
+ :set_heroku_rails_secrets,
19
+ :set_heroku_rails_environment,
20
+ :set_heroku_remotes,
21
+ :set_heroku_application_host,
22
+ :set_heroku_serve_static_files
23
+ )
24
+
25
+ def readme
26
+ template 'README.md.erb', 'README.md'
27
+ end
28
+
29
+ def gitignore
30
+ copy_file "code42_gitignore", ".gitignore"
31
+ end
32
+
33
+ def gemfile
34
+ template "Gemfile.erb", "Gemfile"
35
+ end
36
+
37
+ def provide_setup_script
38
+ template "bin_setup", "bin/setup", force: true
39
+ run "chmod a+x bin/setup"
40
+ end
41
+
42
+ def setup_secret_token
43
+ template 'secrets.yml', 'config/secrets.yml', force: true
44
+ end
45
+
46
+ def copy_rspec_config
47
+ copy_file 'spec_helper.rb', 'spec/spec_helper.rb'
48
+ copy_file 'rails_helper.rb', 'spec/rails_helper.rb'
49
+ end
50
+
51
+ def add_puma_configuration
52
+ copy_file "puma.rb", "config/puma.rb", force: true
53
+ end
54
+
55
+ def use_postgres_config_template
56
+ template 'postgresql_database.yml.erb', 'config/database.yml',
57
+ force: true
58
+ end
59
+
60
+ def create_database
61
+ bundle_command 'exec rake db:create db:migrate'
62
+ end
63
+
64
+ def setup_background_jobs
65
+ copy_file 'active_job.rb', 'config/initializers/active_job.rb'
66
+ copy_file 'sidekiq.yml', 'config/sidekiq.yml'
67
+ end
68
+
69
+ def set_ruby_to_version_being_used
70
+ create_file '.ruby-version', "#{Code42Template::RUBY_VERSION}\n"
71
+ end
72
+
73
+ def configure_time_formats
74
+ remove_file "config/locales/en.yml"
75
+ template "config_locales_pt-BR.yml.erb", "config/locales/pt-BR.yml"
76
+ end
77
+
78
+ def setup_default_directories
79
+ [
80
+ 'app/views/pages',
81
+ 'spec/lib',
82
+ 'spec/controllers',
83
+ 'spec/models',
84
+ 'spec/helpers',
85
+ 'spec/features',
86
+ 'spec/support/matchers',
87
+ 'spec/support/mixins',
88
+ 'spec/support/shared_examples',
89
+ 'spec/factories',
90
+ 'spec/javascripts/unit',
91
+ 'spec/javascripts/integration',
92
+ ].each do |dir|
93
+ empty_directory_with_keep_file dir
94
+ end
95
+ end
96
+
97
+ def copy_dotfiles
98
+ directory("dotfiles", ".")
99
+ end
100
+
101
+ def setup_continuous_integration
102
+ template "travis.yml.erb", '.travis.yml'
103
+ end
104
+
105
+ def init_git
106
+ run 'git init'
107
+ end
108
+
109
+ def create_setup_script
110
+ copy_file 'setup', 'bin/setup', force: true
111
+ end
112
+
113
+ def customize_error_pages
114
+ meta_tags =<<-EOS
115
+ <meta charset="utf-8" />
116
+ <meta name="ROBOTS" content="NOODP" />
117
+ <meta name="viewport" content="initial-scale=1" />
118
+ EOS
119
+
120
+ %w(500 404 422).each do |page|
121
+ inject_into_file "public/#{page}.html", meta_tags, after: "<head>\n"
122
+ replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
123
+ end
124
+ end
125
+
126
+ def remove_uglifier_js_compressor_config
127
+ gsub_file(
128
+ 'config/environments/production.rb',
129
+ /^.+config.assets.js_compressor = :uglifier.*\n/,
130
+ ''
131
+ )
132
+ end
133
+
134
+ def setup_test_env_action_dispatch_exceptions
135
+ gsub_file(
136
+ 'config/environments/test.rb',
137
+ 'config.action_dispatch.show_exceptions = false',
138
+ 'config.action_dispatch.show_exceptions = true'
139
+ )
140
+ end
141
+
142
+ def configure_quiet_assets
143
+ config = <<-RUBY
144
+ config.assets.quiet = true
145
+ RUBY
146
+
147
+ inject_into_class "config/application.rb", "Application", config
148
+ end
149
+
150
+ def setup_spring
151
+ bundle_command "exec spring binstub --all"
152
+ end
153
+
154
+ def setup_javascript
155
+ copy_js_root_files
156
+ copy_js_spec_files
157
+
158
+ copy_webpack_and_karma_config
159
+ copy_webpack_entry_file
160
+ inject_webpack_into_application_layout
161
+
162
+ run "npm install"
163
+ end
164
+
165
+ def copy_js_root_files
166
+ %w(package.json Procfile mocha-webpack.opts).each do |root_file|
167
+ copy_file root_file, root_file
168
+ end
169
+ end
170
+
171
+ def copy_js_spec_files
172
+ %w(
173
+ index.browser.js
174
+ index.integration.js
175
+ unit/smoke.spec.js
176
+ integration/smoke.spec.js
177
+ ).each do |js_spec_file|
178
+ copy_file(
179
+ "spec/javascripts/#{js_spec_file}",
180
+ "spec/javascripts/#{js_spec_file}"
181
+ )
182
+ end
183
+ end
184
+
185
+ def copy_webpack_and_karma_config
186
+ %w(
187
+ karma.conf.js
188
+ webpack.config.js
189
+ webpack.config.test.js
190
+ webpack.config.test.browser.js
191
+ ).each do |config_file|
192
+ copy_file config_file, "config/#{config_file}"
193
+ end
194
+ end
195
+
196
+ def copy_webpack_entry_file
197
+ copy_file(
198
+ "application.js",
199
+ "app/assets/javascripts/application.js",
200
+ force: true
201
+ )
202
+ end
203
+
204
+ def inject_webpack_into_application_layout
205
+ replace_in_file(
206
+ 'app/views/layouts/application.html.erb',
207
+ /javascript_include_tag 'application'/,
208
+ "javascript_include_tag(*webpack_asset_paths('application'))"
209
+ )
210
+ end
211
+
212
+ def configure_feature_tests
213
+ inject_into_file(
214
+ 'config/environments/test.rb',
215
+ " config.webpack.dev_server.enabled = false\n",
216
+ after: "Rails.application.configure do\n",
217
+ )
218
+
219
+ template 'feature_helper.rb.erb', 'spec/feature_helper.rb'
220
+ end
221
+
222
+ def add_bullet_gem_configuration
223
+ config = <<RUBY
224
+ config.after_initialize do
225
+ Bullet.enable = true
226
+ Bullet.bullet_logger = true
227
+ Bullet.rails_logger = true
228
+ end
229
+ RUBY
230
+
231
+ inject_into_file(
232
+ "config/environments/development.rb",
233
+ config,
234
+ after: "config.file_watcher = ActiveSupport::EventedFileUpdateChecker\n",
235
+ )
236
+ end
237
+
238
+ def setup_health_task
239
+ copy_file "health.rake", "lib/tasks/health.rake"
240
+ append_file "Rakefile", %{\ntask default: "health"\n}
241
+ end
242
+
243
+ def setup_webpack_tasks
244
+ copy_file "webpack.rake", "lib/tasks/webpack.rake"
245
+ end
246
+
247
+ def heroku_adapter
248
+ @heroku_adapter ||= Adapters::Heroku.new(self)
249
+ end
250
+ end
251
+ end
@@ -0,0 +1,208 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+ module Code42Template
5
+ class AppGenerator < Rails::Generators::AppGenerator
6
+ class_option :database, type: :string, aliases: "-d", default: "postgresql",
7
+ desc: "Configure for selected database (options: #{DATABASES.join("/")})"
8
+
9
+ class_option :skip_test_unit, type: :boolean, aliases: "-T", default: true,
10
+ desc: "Skip Test::Unit files"
11
+
12
+ class_option :skip_turbolinks, type: :boolean, default: true,
13
+ desc: "Skip turbolinks gem"
14
+
15
+ class_option :skip_bundle, type: :boolean, aliases: "-B", default: true,
16
+ desc: "Don't run bundle install"
17
+
18
+ class_option :heroku, type: :boolean, aliases: "-H", default: false,
19
+ desc: "Create staging and production Heroku apps"
20
+
21
+ class_option :heroku_flags, type: :string, default: "",
22
+ desc: "Set extra Heroku flags"
23
+
24
+ class_option :skip_test, type: :boolean, aliases: '-T', default: true,
25
+ desc: 'Skip test files'
26
+
27
+ def finish_template
28
+ invoke :code42_customization
29
+ super
30
+ end
31
+
32
+ def code42_customization
33
+ invoke :customize_gemfile
34
+ invoke :setup_development_environment
35
+ invoke :setup_test_environment
36
+ invoke :setup_production_environment
37
+ invoke :setup_staging_environment
38
+ invoke :setup_continuous_integration
39
+ invoke :setup_secret_token
40
+ invoke :create_code42_views
41
+ invoke :configure_app
42
+ invoke :customize_error_pages
43
+ invoke :setup_dotfiles
44
+ invoke :setup_git
45
+ invoke :create_setup_script
46
+ invoke :setup_database
47
+ invoke :setup_background_jobs
48
+ invoke :create_local_heroku_setup
49
+ invoke :create_heroku_apps
50
+ invoke :setup_webpack_tasks
51
+ invoke :setup_spring
52
+ invoke :setup_javascript
53
+ end
54
+
55
+ def customize_gemfile
56
+ build :set_ruby_to_version_being_used
57
+
58
+ bundle_command 'install'
59
+ end
60
+
61
+ def setup_database
62
+ say 'Setting up database'
63
+
64
+ if 'postgresql' == options[:database]
65
+ build :use_postgres_config_template
66
+ end
67
+
68
+ build :create_database
69
+ end
70
+
71
+ def setup_background_jobs
72
+ say 'Setting up background jobs'
73
+
74
+ build :setup_background_jogs
75
+ end
76
+
77
+ def create_local_heroku_setup
78
+ say "Creating local Heroku setup"
79
+ build :create_review_apps_setup_script
80
+ build :create_deploy_script
81
+ build :update_readme_with_deploy
82
+ end
83
+
84
+ def create_heroku_apps
85
+ if options[:heroku]
86
+ say "Creating Heroku apps"
87
+ build :create_heroku_apps, options[:heroku_flags]
88
+ build :set_heroku_serve_static_files
89
+ build :set_heroku_remotes
90
+ build :set_heroku_rails_secrets
91
+ build :set_heroku_rails_environment
92
+ build :set_heroku_application_host
93
+ build :create_heroku_pipeline
94
+ build :configure_heroku_buildpacks
95
+ build :configure_automatic_deployment
96
+ end
97
+ end
98
+
99
+ def setup_development_environment
100
+ say 'Setting up the development environment'
101
+ build :add_bullet_gem_configuration
102
+ build :configure_quiet_assets
103
+ end
104
+
105
+ def setup_test_environment
106
+ say 'Setting up the test environment'
107
+
108
+ build :setup_test_env_action_dispatch_exceptions
109
+ build :copy_rspec_config
110
+ build :configure_feature_tests
111
+ end
112
+
113
+ def setup_production_environment
114
+ say 'Setting up the production environment'
115
+
116
+ build :remove_uglifier_js_compressor_config
117
+ end
118
+
119
+ def setup_staging_environment
120
+ say 'Setting up the staging environment'
121
+ end
122
+
123
+ def setup_continuous_integration
124
+ say 'Setting up CI configuration'
125
+
126
+ build :setup_continuous_integration
127
+ end
128
+
129
+ def setup_secret_token
130
+ say 'Moving secret token out of version control'
131
+ end
132
+
133
+ def create_code42_views
134
+ say 'Creating code42 views'
135
+ end
136
+
137
+ def configure_app
138
+ say 'Configuring app'
139
+
140
+ build :add_puma_configuration
141
+ end
142
+
143
+ def setup_git
144
+ if !options[:skip_git]
145
+ say "Initializing git"
146
+ invoke :setup_default_directories
147
+ invoke :init_git
148
+ end
149
+ end
150
+
151
+ def create_setup_script
152
+ say 'Creating a setup script'
153
+
154
+ build :create_setup_script
155
+ end
156
+
157
+ def setup_dotfiles
158
+ build :copy_dotfiles
159
+ end
160
+
161
+ def setup_default_directories
162
+ build :setup_default_directories
163
+ end
164
+
165
+ def setup_webpack_tasks
166
+ say "Setting up webpack tasks"
167
+
168
+ build :setup_webpack_tasks
169
+ end
170
+
171
+ def setup_health_task
172
+ say "Setting up health task"
173
+
174
+ build :setup_health_task
175
+ end
176
+
177
+ def init_git
178
+ build :init_git
179
+ end
180
+
181
+ def customize_error_pages
182
+ say 'Customizing the 500/404/422 pages'
183
+ build :customize_error_pages
184
+ end
185
+
186
+ def setup_spring
187
+ say "Springifying binstubs"
188
+ build :setup_spring
189
+ end
190
+
191
+ def setup_javascript
192
+ say "Setting up javascript environment with NPM and webpack"
193
+ say "This will also run npm install, so hold on..."
194
+
195
+ build :setup_javascript
196
+ end
197
+
198
+ protected
199
+
200
+ def get_builder_class
201
+ Code42Template::AppBuilder
202
+ end
203
+
204
+ def using_active_record?
205
+ !options[:skip_active_record]
206
+ end
207
+ end
208
+ end
@@ -0,0 +1,9 @@
1
+ require 'pathname'
2
+
3
+ module Code42Template
4
+ RAILS_VERSION = "~> 5.0.0"
5
+ RUBY_VERSION = Pathname(__dir__).join('..', '..', '.ruby-version').read.strip
6
+ NODE_VERSION = "6.2.0"
7
+
8
+ VERSION = "2.0.0"
9
+ end
@@ -0,0 +1,5 @@
1
+ require 'code42template/version'
2
+ require "code42template/adapters/heroku"
3
+ require 'code42template/generators/app_generator'
4
+ require 'code42template/actions'
5
+ require 'code42template/app_builder'
@@ -0,0 +1,56 @@
1
+ require "spec_helper"
2
+
3
+ module Code42Template
4
+ module Adapters
5
+ RSpec.describe Heroku do
6
+ it "sets the heroku remotes" do
7
+ setup_file = "bin/setup"
8
+ app_builder = double(app_name: app_name)
9
+ allow(app_builder).to receive(:append_file)
10
+
11
+ Heroku.new(app_builder).set_heroku_remotes
12
+
13
+ expect(app_builder).to have_received(:append_file)
14
+ .with(setup_file, /heroku join --app #{app_name.dasherize}-production/)
15
+ expect(app_builder).to have_received(:append_file)
16
+ .with(setup_file, /heroku join --app #{app_name.dasherize}-staging/)
17
+ end
18
+
19
+ it "sets the heroku rails secrets" do
20
+ app_builder = double(app_name: app_name)
21
+ allow(app_builder).to receive(:run)
22
+
23
+ Heroku.new(app_builder).set_heroku_rails_secrets
24
+
25
+ expect(app_builder).to(
26
+ have_configured_var("staging", "SECRET_KEY_BASE")
27
+ )
28
+ expect(app_builder).to(
29
+ have_configured_var("production", "SECRET_KEY_BASE")
30
+ )
31
+ end
32
+
33
+ it "sets the application host" do
34
+ app_builder = double(app_name: app_name)
35
+ allow(app_builder).to receive(:run)
36
+
37
+ Heroku.new(app_builder).set_heroku_application_host
38
+
39
+ expect(app_builder).to(
40
+ have_configured_var("staging", "APPLICATION_HOST")
41
+ )
42
+ expect(app_builder).to(
43
+ have_configured_var("production", "APPLICATION_HOST")
44
+ )
45
+ end
46
+
47
+ def app_name
48
+ Code42TemplateTestHelpers::APP_NAME
49
+ end
50
+
51
+ def have_configured_var(remote_name, var)
52
+ have_received(:run).with(/config:add #{var}=.+ --remote #{remote_name}/)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,58 @@
1
+ module Code42TemplateTestHelpers
2
+ APP_NAME = "dummy_app"
3
+
4
+ def remove_project_directory
5
+ FileUtils.rm_rf(project_path)
6
+ end
7
+
8
+ def create_tmp_directory
9
+ FileUtils.mkdir_p(tmp_path)
10
+ end
11
+
12
+ def run_code42template(arguments = nil)
13
+ Dir.chdir(tmp_path) do
14
+ Bundler.with_clean_env do
15
+ add_fakes_to_path
16
+ `
17
+ #{code42template_bin} #{APP_NAME} #{arguments}
18
+ `
19
+ end
20
+ end
21
+ end
22
+
23
+ def drop_dummy_database
24
+ if File.exist?(project_path)
25
+ Dir.chdir(project_path) do
26
+ Bundler.with_clean_env do
27
+ `rake db:drop`
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ def add_fakes_to_path
34
+ ENV["PATH"] = "#{support_bin}:#{ENV['PATH']}"
35
+ end
36
+
37
+ def project_path
38
+ @project_path ||= Pathname.new("#{tmp_path}/#{APP_NAME}")
39
+ end
40
+
41
+ private
42
+
43
+ def tmp_path
44
+ @tmp_path ||= Pathname.new("#{root_path}/tmp")
45
+ end
46
+
47
+ def code42template_bin
48
+ File.join(root_path, 'bin', 'code42template')
49
+ end
50
+
51
+ def support_bin
52
+ File.join(root_path, "spec", "fakes", "bin")
53
+ end
54
+
55
+ def root_path
56
+ Pathname(__dir__).join('..')
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', '..', 'support', 'fake_heroku'), File.dirname(__FILE__))
4
+
5
+ FakeHeroku.new(ARGV).run!
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', '..', 'support', 'fake_github'), File.dirname(__FILE__))
4
+
5
+ FakeGithub.new(ARGV).run!
@@ -0,0 +1,83 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Heroku" do
4
+ context "--heroku" do
5
+ before(:all) do
6
+ clean_up
7
+ run_code42template("--heroku=true")
8
+ setup_app_dependencies
9
+ end
10
+
11
+ it "suspends a project for Heroku" do
12
+ app_name = Code42TemplateTestHelpers::APP_NAME.dasherize
13
+
14
+ expect(FakeHeroku).to have_created_app_for("staging")
15
+ expect(FakeHeroku).to have_created_app_for("production")
16
+ expect(FakeHeroku).to have_configured_vars("staging", "SECRET_KEY_BASE")
17
+ expect(FakeHeroku).to(
18
+ have_configured_vars('production', 'SECRET_KEY_BASE')
19
+ )
20
+ expect(FakeHeroku).to(
21
+ have_configured_vars("staging", "RAILS_ENV", "production")
22
+ )
23
+ expect(FakeHeroku).to(
24
+ have_configured_vars("production", "RAILS_ENV", "production")
25
+ )
26
+ expect(FakeHeroku).to have_configured_vars(
27
+ 'staging',
28
+ 'APPLICATION_HOST',
29
+ )
30
+ expect(FakeHeroku).to have_configured_vars(
31
+ 'production',
32
+ 'APPLICATION_HOST',
33
+ )
34
+ expect(FakeHeroku).to have_setup_pipeline_for(app_name)
35
+
36
+ buildpack_urls = %w(
37
+ heroku/nodejs
38
+ heroku/ruby
39
+ https://github.com/febeling/webpack-rails-buildpack.git
40
+ )
41
+ expect(FakeHeroku).to have_configured_buildpacks_sequentially(
42
+ 'staging',
43
+ buildpack_urls
44
+ )
45
+ expect(FakeHeroku).to have_configured_buildpacks_sequentially(
46
+ 'production',
47
+ buildpack_urls
48
+ )
49
+
50
+ bin_setup_path = "#{project_path}/bin/setup"
51
+ bin_setup = IO.read(bin_setup_path)
52
+
53
+ expect(bin_setup).to include("heroku join --app #{app_name}-production")
54
+ expect(bin_setup).to include("heroku join --app #{app_name}-staging")
55
+ expect(bin_setup).to include('git config heroku.remote staging')
56
+ expect(File.stat(bin_setup_path)).to be_executable
57
+
58
+ readme = IO.read("#{project_path}/README.md")
59
+
60
+ expect(readme).to include('./bin/deploy staging')
61
+ expect(readme).to include('./bin/deploy production')
62
+ end
63
+ end
64
+
65
+ context "--heroku with region flag" do
66
+ before(:all) do
67
+ clean_up
68
+ run_code42template(%{--heroku=true --heroku-flags="--region eu"})
69
+ setup_app_dependencies
70
+ end
71
+
72
+ it 'suspends a project with extra Heroku flags' do
73
+ expect(FakeHeroku).to have_created_app_for('staging', '--region eu')
74
+ expect(FakeHeroku).to have_created_app_for('production', '--region eu')
75
+ end
76
+ end
77
+
78
+ def clean_up
79
+ drop_dummy_database
80
+ remove_project_directory
81
+ FakeHeroku.clear!
82
+ end
83
+ end