cosmit-suspenders 1.36.0

Sign up to get free protection for your applications and to get access to all the features.
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/CONTRIBUTING.md +51 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +21 -0
  8. data/NEWS.md +475 -0
  9. data/README.md +226 -0
  10. data/RELEASING.md +19 -0
  11. data/Rakefile +8 -0
  12. data/bin/rake +16 -0
  13. data/bin/rspec +16 -0
  14. data/bin/setup +13 -0
  15. data/bin/suspenders +18 -0
  16. data/lib/suspenders/actions.rb +33 -0
  17. data/lib/suspenders/adapters/heroku.rb +125 -0
  18. data/lib/suspenders/app_builder.rb +512 -0
  19. data/lib/suspenders/generators/app_generator.rb +254 -0
  20. data/lib/suspenders/version.rb +5 -0
  21. data/lib/suspenders.rb +5 -0
  22. data/spec/adapters/heroku_spec.rb +52 -0
  23. data/spec/fakes/bin/heroku +5 -0
  24. data/spec/fakes/bin/hub +5 -0
  25. data/spec/features/github_spec.rb +15 -0
  26. data/spec/features/heroku_spec.rb +93 -0
  27. data/spec/features/new_project_spec.rb +215 -0
  28. data/spec/spec_helper.rb +20 -0
  29. data/spec/support/fake_github.rb +21 -0
  30. data/spec/support/fake_heroku.rb +53 -0
  31. data/spec/support/suspenders.rb +58 -0
  32. data/suspenders.gemspec +37 -0
  33. data/templates/Gemfile.erb +63 -0
  34. data/templates/Procfile +1 -0
  35. data/templates/README.md.erb +64 -0
  36. data/templates/_flash.html.slim +6 -0
  37. data/templates/_javascript.html.slim +29 -0
  38. data/templates/action_mailer.rb +5 -0
  39. data/templates/app.json.erb +40 -0
  40. data/templates/application.scss +6 -0
  41. data/templates/bin_deploy +12 -0
  42. data/templates/bin_setup +21 -0
  43. data/templates/bin_setup_review_app.erb +19 -0
  44. data/templates/browserslist +4 -0
  45. data/templates/bundler_audit.rake +12 -0
  46. data/templates/capybara_webkit.rb +5 -0
  47. data/templates/circle.yml.erb +6 -0
  48. data/templates/config_locales_en.yml.erb +19 -0
  49. data/templates/database_cleaner_rspec.rb +21 -0
  50. data/templates/dev.rake +12 -0
  51. data/templates/disable_xml_params.rb +1 -0
  52. data/templates/dotfiles/.ctags +2 -0
  53. data/templates/dotfiles/.env +13 -0
  54. data/templates/errors.rb +34 -0
  55. data/templates/factories.rb +2 -0
  56. data/templates/factory_girl_rspec.rb +3 -0
  57. data/templates/hound.yml +14 -0
  58. data/templates/i18n.rb +3 -0
  59. data/templates/json_encoding.rb +1 -0
  60. data/templates/newrelic.yml.erb +34 -0
  61. data/templates/postgresql_database.yml.erb +21 -0
  62. data/templates/rack_mini_profiler.rb +5 -0
  63. data/templates/rails_helper.rb +22 -0
  64. data/templates/secrets.yml +15 -0
  65. data/templates/shoulda_matchers_config_rspec.rb +6 -0
  66. data/templates/smtp.rb +9 -0
  67. data/templates/spec_helper.rb +29 -0
  68. data/templates/staging.rb +5 -0
  69. data/templates/suspenders_gitignore +15 -0
  70. data/templates/suspenders_layout.html.slim.erb +24 -0
  71. metadata +213 -0
@@ -0,0 +1,254 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+ module Suspenders
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 :heroku, type: :boolean, aliases: "-H", default: false,
10
+ desc: "Create staging and production Heroku apps"
11
+
12
+ class_option :heroku_flags, type: :string, default: "",
13
+ desc: "Set extra Heroku flags"
14
+
15
+ class_option :github, type: :string, aliases: "-G", default: nil,
16
+ desc: "Create Github repository and add remote origin pointed to repo"
17
+
18
+ class_option :skip_test_unit, type: :boolean, aliases: "-T", default: true,
19
+ desc: "Skip Test::Unit files"
20
+
21
+ class_option :skip_turbolinks, type: :boolean, default: true,
22
+ desc: "Skip turbolinks gem"
23
+
24
+ class_option :skip_bundle, type: :boolean, aliases: "-B", default: true,
25
+ desc: "Don't run bundle install"
26
+
27
+ def finish_template
28
+ invoke :suspenders_customization
29
+ super
30
+ end
31
+
32
+ def suspenders_customization
33
+ invoke :customize_gemfile
34
+ invoke :setup_simple_form
35
+ invoke :setup_devise
36
+ invoke :setup_initjs
37
+ invoke :setup_development_environment
38
+ invoke :setup_test_environment
39
+ invoke :setup_production_environment
40
+ invoke :setup_staging_environment
41
+ invoke :setup_secret_token
42
+ invoke :create_suspenders_views
43
+ invoke :configure_app
44
+ invoke :setup_stylesheets
45
+ invoke :copy_miscellaneous_files
46
+ invoke :customize_error_pages
47
+ invoke :remove_config_comment_lines
48
+ invoke :remove_routes_comment_lines
49
+ invoke :setup_dotfiles
50
+ invoke :setup_git
51
+ invoke :setup_database
52
+ invoke :create_heroku_apps
53
+ invoke :create_github_repo
54
+ invoke :setup_bundler_audit
55
+ invoke :setup_spring
56
+ invoke :setup_active_admin
57
+ invoke :outro
58
+ end
59
+
60
+ def customize_gemfile
61
+ build :set_ruby_to_version_being_used
62
+
63
+ if options[:heroku]
64
+ build :set_up_heroku_specific_gems
65
+ end
66
+
67
+ bundle_command 'install'
68
+ end
69
+
70
+ def setup_simple_form
71
+ build :configure_simple_form
72
+ end
73
+
74
+ def setup_devise
75
+ build :configure_devise
76
+ end
77
+
78
+ def setup_initjs
79
+ build :configure_initjs
80
+ end
81
+
82
+ def setup_active_admin
83
+ build :configure_active_admin
84
+ end
85
+
86
+ def setup_database
87
+ say 'Setting up database'
88
+
89
+ if 'postgresql' == options[:database]
90
+ build :use_postgres_config_template
91
+ end
92
+
93
+ build :create_database
94
+ end
95
+
96
+ def setup_development_environment
97
+ say 'Setting up the development environment'
98
+ build :raise_on_missing_assets_in_test
99
+ build :raise_on_delivery_errors
100
+ build :set_test_delivery_method
101
+ build :add_bullet_gem_configuration
102
+ build :raise_on_unpermitted_parameters
103
+ build :provide_setup_script
104
+ build :provide_dev_prime_task
105
+ build :configure_generators
106
+ build :configure_i18n_for_missing_translations
107
+ build :configure_quiet_assets
108
+ end
109
+
110
+ def setup_test_environment
111
+ say 'Setting up the test environment'
112
+ build :set_up_factory_girl_for_rspec
113
+ build :generate_factories_file
114
+ build :set_up_hound
115
+ build :generate_rspec
116
+ build :configure_rspec
117
+ build :configure_background_jobs_for_rspec
118
+ build :enable_database_cleaner
119
+ build :provide_shoulda_matchers_config
120
+ build :configure_spec_support_features
121
+ build :configure_ci
122
+ build :configure_i18n_for_test_environment
123
+ build :configure_action_mailer_in_specs
124
+ build :configure_capybara_webkit
125
+ end
126
+
127
+ def setup_production_environment
128
+ say 'Setting up the production environment'
129
+ build :configure_smtp
130
+ build :configure_rack_timeout
131
+ build :enable_rack_canonical_host
132
+ build :enable_rack_deflater
133
+ build :setup_asset_host
134
+ end
135
+
136
+ def setup_staging_environment
137
+ say 'Setting up the staging environment'
138
+ build :setup_staging_environment
139
+ end
140
+
141
+ def setup_secret_token
142
+ say 'Moving secret token out of version control'
143
+ build :setup_secret_token
144
+ end
145
+
146
+ def create_suspenders_views
147
+ say 'Creating suspenders views'
148
+ build :create_partials_directory
149
+ build :create_shared_flashes
150
+ build :create_shared_javascripts
151
+ build :create_application_layout
152
+ end
153
+
154
+ def configure_app
155
+ say 'Configuring app'
156
+ build :configure_action_mailer
157
+ build :configure_active_job
158
+ build :configure_time_formats
159
+ build :disable_xml_params
160
+ build :setup_default_rake_task
161
+ build :set_up_forego
162
+ build :setup_rack_mini_profiler
163
+ end
164
+
165
+ def setup_stylesheets
166
+ say 'Set up stylesheets'
167
+ build :setup_stylesheets
168
+ end
169
+
170
+ def setup_git
171
+ if !options[:skip_git]
172
+ say "Initializing git"
173
+ invoke :setup_default_directories
174
+ invoke :init_git
175
+ end
176
+ end
177
+
178
+ def create_heroku_apps
179
+ if options[:heroku]
180
+ say "Creating Heroku apps"
181
+ build :create_heroku_apps, options[:heroku_flags]
182
+ build :provide_review_apps_setup_script
183
+ build :set_heroku_serve_static_files
184
+ build :set_heroku_remotes
185
+ build :set_heroku_rails_secrets
186
+ build :create_heroku_pipelines_config_file
187
+ build :create_heroku_pipeline
188
+ build :provide_deploy_script
189
+ build :configure_automatic_deployment
190
+ end
191
+ end
192
+
193
+ def create_github_repo
194
+ if !options[:skip_git] && options[:github]
195
+ say 'Creating Github repo'
196
+ build :create_github_repo, options[:github]
197
+ end
198
+ end
199
+
200
+ def setup_dotfiles
201
+ build :copy_dotfiles
202
+ end
203
+
204
+ def setup_default_directories
205
+ build :setup_default_directories
206
+ end
207
+
208
+ def setup_bundler_audit
209
+ say "Setting up bundler-audit"
210
+ build :setup_bundler_audit
211
+ end
212
+
213
+ def setup_spring
214
+ say "Springifying binstubs"
215
+ build :setup_spring
216
+ end
217
+
218
+ def init_git
219
+ build :init_git
220
+ end
221
+
222
+ def copy_miscellaneous_files
223
+ say 'Copying miscellaneous support files'
224
+ build :copy_miscellaneous_files
225
+ end
226
+
227
+ def customize_error_pages
228
+ say 'Customizing the 500/404/422 pages'
229
+ build :customize_error_pages
230
+ end
231
+
232
+ def remove_config_comment_lines
233
+ build :remove_config_comment_lines
234
+ end
235
+
236
+ def remove_routes_comment_lines
237
+ build :remove_routes_comment_lines
238
+ end
239
+
240
+ def outro
241
+ say 'Congratulations! You just pulled our suspenders.'
242
+ end
243
+
244
+ protected
245
+
246
+ def get_builder_class
247
+ Suspenders::AppBuilder
248
+ end
249
+
250
+ def using_active_record?
251
+ !options[:skip_active_record]
252
+ end
253
+ end
254
+ end
@@ -0,0 +1,5 @@
1
+ module Suspenders
2
+ RAILS_VERSION = "~> 4.2.0"
3
+ RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
4
+ VERSION = "1.36.0"
5
+ end
data/lib/suspenders.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'suspenders/version'
2
+ require 'suspenders/generators/app_generator'
3
+ require 'suspenders/actions'
4
+ require "suspenders/adapters/heroku"
5
+ require 'suspenders/app_builder'
@@ -0,0 +1,52 @@
1
+ require "spec_helper"
2
+
3
+ module Suspenders
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 up the heroku specific gems" do
20
+ app_builder = double(app_name: app_name)
21
+ allow(app_builder).to receive(:inject_into_file)
22
+
23
+ Heroku.new(app_builder).set_up_heroku_specific_gems
24
+
25
+ expect(app_builder).to have_received(:inject_into_file).
26
+ with("Gemfile", /rails_stdout_logging/, anything)
27
+ end
28
+
29
+ it "sets the heroku rails secrets" do
30
+ app_builder = double(app_name: app_name)
31
+ allow(app_builder).to receive(:run)
32
+
33
+ Heroku.new(app_builder).set_heroku_rails_secrets
34
+
35
+ expect(app_builder).to(
36
+ have_configured_var("staging", "SECRET_KEY_BASE"),
37
+ )
38
+ expect(app_builder).to(
39
+ have_configured_var("production", "SECRET_KEY_BASE"),
40
+ )
41
+ end
42
+
43
+ def app_name
44
+ SuspendersTestHelpers::APP_NAME
45
+ end
46
+
47
+ def have_configured_var(remote_name, var)
48
+ have_received(:run).with(/config:add #{var}=.+ --remote #{remote_name}/)
49
+ end
50
+ end
51
+ end
52
+ 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,15 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "GitHub" do
4
+ before do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ end
8
+
9
+ it "suspends a project with --github option" do
10
+ repo_name = 'test'
11
+ run_suspenders("--github=#{repo_name}")
12
+
13
+ expect(FakeGithub).to have_created_repo(repo_name)
14
+ end
15
+ end
@@ -0,0 +1,93 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Heroku" do
4
+ context "--heroku" do
5
+ before(:all) do
6
+ clean_up
7
+ run_suspenders("--heroku=true")
8
+ end
9
+
10
+ it "suspends a project for Heroku" do
11
+ app_name = SuspendersTestHelpers::APP_NAME.dasherize
12
+
13
+ expect(FakeHeroku).to(
14
+ have_gem_included(project_path, "rails_stdout_logging"),
15
+ )
16
+ expect(FakeHeroku).to have_created_app_for("staging")
17
+ expect(FakeHeroku).to have_created_app_for("production")
18
+ expect(FakeHeroku).to have_configured_vars("staging", "SECRET_KEY_BASE")
19
+ expect(FakeHeroku).to have_configured_vars(
20
+ "production",
21
+ "SECRET_KEY_BASE",
22
+ )
23
+ expect(FakeHeroku).to have_setup_pipeline_for(app_name)
24
+
25
+ bin_setup_path = "#{project_path}/bin/setup"
26
+ bin_setup = IO.read(bin_setup_path)
27
+
28
+ expect(bin_setup).to include("heroku join --app #{app_name}-production")
29
+ expect(bin_setup).to include("heroku join --app #{app_name}-staging")
30
+ expect(bin_setup).to include("git config heroku.remote staging")
31
+ expect(File.stat(bin_setup_path)).to be_executable
32
+
33
+ bin_setup_path = "#{project_path}/bin/setup_review_app"
34
+ bin_setup = IO.read(bin_setup_path)
35
+
36
+ expect(bin_setup).to include("heroku run rake db:migrate --app #{app_name}-staging-pr-$1")
37
+ expect(bin_setup).to include("heroku ps:scale worker=1 --app #{app_name}-staging-pr-$1")
38
+ expect(bin_setup).to include("heroku restart --app #{app_name}-staging-pr-$1")
39
+ expect(File.stat(bin_setup_path)).to be_executable
40
+
41
+ bin_deploy_path = "#{project_path}/bin/deploy"
42
+ bin_deploy = IO.read(bin_deploy_path)
43
+
44
+ expect(bin_deploy).to include("heroku run rake db:migrate")
45
+ expect(File.stat(bin_deploy_path)).to be_executable
46
+
47
+ readme = IO.read("#{project_path}/README.md")
48
+
49
+ expect(readme).to include("./bin/deploy staging")
50
+ expect(readme).to include("./bin/deploy production")
51
+
52
+ circle_yml_path = "#{project_path}/circle.yml"
53
+ circle_yml = IO.read(circle_yml_path)
54
+
55
+ expect(circle_yml).to include <<-YML.strip_heredoc
56
+ deployment:
57
+ staging:
58
+ branch: master
59
+ commands:
60
+ - bin/deploy staging
61
+ YML
62
+ end
63
+
64
+ it "adds app.json file" do
65
+ expect(File).to exist("#{project_path}/app.json")
66
+ end
67
+
68
+ it "includes application name in app.json file" do
69
+ app_json_file = IO.read("#{project_path}/app.json")
70
+ app_name = SuspendersTestHelpers::APP_NAME.dasherize
71
+
72
+ expect(app_json_file).to match(/"name":"#{app_name}"/)
73
+ end
74
+ end
75
+
76
+ context "--heroku with region flag" do
77
+ before(:all) do
78
+ clean_up
79
+ run_suspenders(%{--heroku=true --heroku-flags="--region eu"})
80
+ end
81
+
82
+ it "suspends a project with extra Heroku flags" do
83
+ expect(FakeHeroku).to have_created_app_for("staging", "--region eu")
84
+ expect(FakeHeroku).to have_created_app_for("production", "--region eu")
85
+ end
86
+ end
87
+
88
+ def clean_up
89
+ drop_dummy_database
90
+ remove_project_directory
91
+ FakeHeroku.clear!
92
+ end
93
+ end
@@ -0,0 +1,215 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Suspend a new project with default configuration" do
4
+ before(:all) do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ run_suspenders
8
+ end
9
+
10
+ it "uses custom Gemfile" do
11
+ gemfile_file = IO.read("#{project_path}/Gemfile")
12
+ expect(gemfile_file).to match(
13
+ /^ruby "#{Suspenders::RUBY_VERSION}"$/,
14
+ )
15
+ expect(gemfile_file).to match(
16
+ /^gem "autoprefixer-rails"$/,
17
+ )
18
+ expect(gemfile_file).to match(
19
+ /^gem "rails", "#{Suspenders::RAILS_VERSION}"$/,
20
+ )
21
+ end
22
+
23
+ it "ensures project specs pass" do
24
+ Dir.chdir(project_path) do
25
+ Bundler.with_clean_env do
26
+ expect(`rake`).to include('0 failures')
27
+ end
28
+ end
29
+ end
30
+
31
+ it "inherits staging config from production" do
32
+ staging_file = IO.read("#{project_path}/config/environments/staging.rb")
33
+ config_stub = "Rails.application.configure do"
34
+
35
+ expect(staging_file).to match(/^require_relative "production"/)
36
+ expect(staging_file).to match(/#{config_stub}/), staging_file
37
+ end
38
+
39
+ it "creates .ruby-version from Suspenders .ruby-version" do
40
+ ruby_version_file = IO.read("#{project_path}/.ruby-version")
41
+
42
+ expect(ruby_version_file).to eq "#{RUBY_VERSION}\n"
43
+ end
44
+
45
+ it "copies dotfiles" do
46
+ %w[.ctags .env].each do |dotfile|
47
+ expect(File).to exist("#{project_path}/#{dotfile}")
48
+ end
49
+ end
50
+
51
+ it "loads secret_key_base from env" do
52
+ secrets_file = IO.read("#{project_path}/config/secrets.yml")
53
+
54
+ expect(secrets_file).to match(/secret_key_base: <%= ENV\["SECRET_KEY_BASE"\] %>/)
55
+ end
56
+
57
+ it "adds bin/setup file" do
58
+ expect(File).to exist("#{project_path}/bin/setup")
59
+ end
60
+
61
+ it "makes bin/setup executable" do
62
+ bin_setup_path = "#{project_path}/bin/setup"
63
+
64
+ expect(File.stat(bin_setup_path)).to be_executable
65
+ end
66
+
67
+ it "adds support file for action mailer" do
68
+ expect(File).to exist("#{project_path}/spec/support/action_mailer.rb")
69
+ end
70
+
71
+ it "configures capybara-webkit" do
72
+ expect(File).to exist("#{project_path}/spec/support/capybara_webkit.rb")
73
+ end
74
+
75
+ it "adds support file for i18n" do
76
+ expect(File).to exist("#{project_path}/spec/support/i18n.rb")
77
+ end
78
+
79
+ it "creates good default .hound.yml" do
80
+ hound_config_file = IO.read("#{project_path}/.hound.yml")
81
+
82
+ expect(hound_config_file).to include "enabled: true"
83
+ end
84
+
85
+ it "ensures Gemfile contains `rack-mini-profiler`" do
86
+ gemfile = IO.read("#{project_path}/Gemfile")
87
+
88
+ expect(gemfile).to include %{gem "rack-mini-profiler", require: false}
89
+ end
90
+
91
+ it "ensures .sample.env defaults to RACK_MINI_PROFILER=0" do
92
+ env = IO.read("#{project_path}/.env")
93
+
94
+ expect(env).to include "RACK_MINI_PROFILER=0"
95
+ end
96
+
97
+ it "creates a rack-mini-profiler initializer" do
98
+ expect(File).
99
+ to exist("#{project_path}/config/initializers/rack_mini_profiler.rb")
100
+ end
101
+
102
+ it "raises on unpermitted parameters in all environments" do
103
+ result = IO.read("#{project_path}/config/application.rb")
104
+
105
+ expect(result).to match(
106
+ /^ +config.action_controller.action_on_unpermitted_parameters = :raise$/
107
+ )
108
+ end
109
+
110
+ it "adds explicit quiet_assets configuration" do
111
+ result = IO.read("#{project_path}/config/application.rb")
112
+
113
+ expect(result).to match(
114
+ /^ +config.quiet_assets = true$/
115
+ )
116
+ end
117
+
118
+ it "raises on missing translations in development and test" do
119
+ %w[development test].each do |environment|
120
+ environment_file =
121
+ IO.read("#{project_path}/config/environments/#{environment}.rb")
122
+ expect(environment_file).to match(
123
+ /^ +config.action_view.raise_on_missing_translations = true$/
124
+ )
125
+ end
126
+ end
127
+
128
+ it "evaluates en.yml.erb" do
129
+ locales_en_file = IO.read("#{project_path}/config/locales/en.yml")
130
+
131
+ expect(locales_en_file).to match(/application: #{app_name.humanize}/)
132
+ end
133
+
134
+ it "configs simple_form" do
135
+ expect(File).to exist("#{project_path}/config/initializers/simple_form.rb")
136
+ end
137
+
138
+ it "configs :test email delivery method for development" do
139
+ dev_env_file = IO.read("#{project_path}/config/environments/development.rb")
140
+ expect(dev_env_file).
141
+ to match(/^ +config.action_mailer.delivery_method = :test$/)
142
+ end
143
+
144
+ it "uses APPLICATION_HOST, not HOST in the production config" do
145
+ prod_env_file = IO.read("#{project_path}/config/environments/production.rb")
146
+ expect(prod_env_file).to match(/"APPLICATION_HOST"/)
147
+ expect(prod_env_file).not_to match(/"HOST"/)
148
+ end
149
+
150
+ it "configures language in html element" do
151
+ layout_path = "/app/views/layouts/application.html.erb"
152
+ layout_file = IO.read("#{project_path}#{layout_path}")
153
+ expect(layout_file).to match(/<html lang="en">/)
154
+ end
155
+
156
+ it "configs active job queue adapter" do
157
+ application_config = IO.read("#{project_path}/config/application.rb")
158
+ test_config = IO.read("#{project_path}/config/environments/test.rb")
159
+
160
+ expect(application_config).to match(
161
+ /^ +config.active_job.queue_adapter = :delayed_job$/
162
+ )
163
+ expect(test_config).to match(
164
+ /^ +config.active_job.queue_adapter = :inline$/
165
+ )
166
+ end
167
+
168
+ it "configs bullet gem in development" do
169
+ test_config = IO.read("#{project_path}/config/environments/development.rb")
170
+
171
+ expect(test_config).to match /^ +Bullet.enable = true$/
172
+ expect(test_config).to match /^ +Bullet.bullet_logger = true$/
173
+ expect(test_config).to match /^ +Bullet.rails_logger = true$/
174
+ end
175
+
176
+ it "configs missing assets to raise in test" do
177
+ test_config = IO.read("#{project_path}/config/environments/test.rb")
178
+
179
+ expect(test_config).to match(
180
+ /^ +config.assets.raise_runtime_errors = true$/,
181
+ )
182
+ end
183
+
184
+ it "adds spring to binstubs" do
185
+ expect(File).to exist("#{project_path}/bin/spring")
186
+
187
+ bin_stubs = %w(rake rails rspec)
188
+ bin_stubs.each do |bin_stub|
189
+ expect(IO.read("#{project_path}/bin/#{bin_stub}")).to match(/spring/)
190
+ end
191
+ end
192
+
193
+ it "removes comments and extra newlines from config files" do
194
+ config_files = [
195
+ IO.read("#{project_path}/config/application.rb"),
196
+ IO.read("#{project_path}/config/environment.rb"),
197
+ IO.read("#{project_path}/config/environments/development.rb"),
198
+ IO.read("#{project_path}/config/environments/production.rb"),
199
+ IO.read("#{project_path}/config/environments/test.rb"),
200
+ ]
201
+
202
+ config_files.each do |file|
203
+ expect(file).not_to match(/.*#.*/)
204
+ expect(file).not_to match(/^$\n/)
205
+ end
206
+ end
207
+
208
+ it "copies factories.rb" do
209
+ expect(File).to exist("#{project_path}/spec/factories.rb")
210
+ end
211
+
212
+ def app_name
213
+ SuspendersTestHelpers::APP_NAME
214
+ end
215
+ end