suspenders 1.45.0 → 1.46.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +2 -1
  4. data/CONTRIBUTING.md +8 -0
  5. data/NEWS.md +20 -0
  6. data/README.md +1 -1
  7. data/lib/suspenders.rb +16 -7
  8. data/lib/suspenders/actions.rb +1 -9
  9. data/lib/suspenders/app_builder.rb +2 -120
  10. data/lib/suspenders/generators/analytics_generator.rb +29 -0
  11. data/lib/suspenders/generators/app_generator.rb +12 -41
  12. data/lib/suspenders/generators/ci_generator.rb +26 -0
  13. data/lib/suspenders/generators/db_optimizations_generator.rb +29 -0
  14. data/lib/suspenders/generators/factories_generator.rb +26 -0
  15. data/lib/suspenders/generators/forms_generator.rb +18 -0
  16. data/lib/suspenders/generators/jobs_generator.rb +47 -0
  17. data/lib/suspenders/generators/js_driver_generator.rb +18 -0
  18. data/lib/suspenders/generators/lint_generator.rb +14 -0
  19. data/lib/suspenders/generators/stylesheet_base_generator.rb +1 -1
  20. data/lib/suspenders/generators/testing_generator.rb +60 -0
  21. data/lib/suspenders/generators/views_generator.rb +35 -0
  22. data/lib/suspenders/version.rb +2 -2
  23. data/spec/features/new_project_spec.rb +9 -1
  24. data/spec/support/suspenders.rb +17 -4
  25. data/suspenders.gemspec +1 -1
  26. data/templates/Gemfile.erb +1 -10
  27. data/templates/_javascript.html.erb +0 -2
  28. data/templates/circle.yml.erb +1 -1
  29. data/templates/dev.rake +2 -2
  30. data/templates/factories.rb +1 -1
  31. data/templates/factory_bot_rspec.rb +3 -0
  32. data/templates/rails_helper.rb +1 -1
  33. data/templates/spec_helper.rb +0 -5
  34. metadata +18 -24
  35. data/lib/suspenders/generators/initialize_active_job_generator.rb +0 -19
  36. data/templates/database_cleaner_rspec.rb +0 -21
  37. data/templates/factory_girl_rspec.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 253fc6f3c173bce9e7858831161cf75924094222
4
- data.tar.gz: 947de81dd1fc955c04f13ea1260e4391b505b0f2
2
+ SHA256:
3
+ metadata.gz: 5e456d8de3863b0f24364c29696229e699488cbe187aca31ee6abde4ed512e5a
4
+ data.tar.gz: d06e8ae58fff1ab88ec50db76194af8da542ff9485eb73af0014f1e7bf87efc1
5
5
  SHA512:
6
- metadata.gz: 003c8627d76eaad3f8a51f404608dc1cd66ee35dbaba8b45cf6f5ef0e9a06fc4fe7f826f9f387a51118d2670df7499a46b83a7441541e21f5a0b691a08a0e063
7
- data.tar.gz: 3a08ab29152033941e6a1b2baba20743d2992ab9872e590e7815007cadcbba37514700cc6f9deaed72f02408458a21d1ed020f15c1e060e16250bd7da01a5553
6
+ metadata.gz: b4a3ab9fdf134a6d2504c2c9110471df7252c545da046897c91504333f4c0dff88b486bda56f554d6cd8cec66ab2fdca732434afe51dc1952c211bc9b564db57
7
+ data.tar.gz: 46cdb956f84eb6fed1fcbd9e095974d4ffac51a65093debe0a73d80bee19e7d441bc7cd815a75c942d325c7c06d9c975b4efc0dbf7e03ab29ac64c012dc4e03a
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.1
1
+ 2.5.0
data/.travis.yml CHANGED
@@ -1,11 +1,12 @@
1
1
  language: ruby
2
- rvm: 2.4.1
2
+ rvm: 2.5.0
3
3
  cache: bundler
4
4
  sudo: false
5
5
  before_install:
6
6
  - "echo '--colour' > ~/.rspec"
7
7
  - git config --global user.name 'Travis CI'
8
8
  - git config --global user.email 'travis-ci@example.com'
9
+ - gem update --system
9
10
  install: bundle install
10
11
  notifications:
11
12
  email: false
data/CONTRIBUTING.md CHANGED
@@ -52,3 +52,11 @@ We may suggest changes.
52
52
 
53
53
  To update the Ruby version,
54
54
  change `.ruby-version` and `.travis.yml`.
55
+
56
+ If you see this error while running tests:
57
+
58
+ ```
59
+ Your Ruby version is XXX, but your Gemfile specified YYY (Bundler::RubyVersionMismatch)
60
+ ```
61
+
62
+ Try removing the `tmp/` directory and re-running the tests.
data/NEWS.md CHANGED
@@ -1,3 +1,23 @@
1
+ 1.46.0 (January 26, 2018)
2
+
3
+ * Bug fix: Fix for action mailer asset_host
4
+ * Bug fix: Lock pg to ~> 0.18
5
+ * Breaking: Remove Database Cleaner
6
+ * Upgrade: Update to Rails 5.1.4
7
+ * Upgrade: Update to Ruby 2.5.0
8
+ * Upgrade: Update bourbon from 5.0.0.beta.8 to 5.0.0
9
+ * Upgrade: Update FactoryGirl to FactoryBot
10
+ * Generators: Analytics generator
11
+ * Generators: CI generator
12
+ * Generators: DB optimization generator
13
+ * Generators: Factories generator
14
+ * Generators: Forms generator
15
+ * Generators: Javascript driver generator
16
+ * Generators: Jobs generator
17
+ * Generators: Lint generator
18
+ * Generators: Testing driver generator
19
+ * Generators: Views generator
20
+
1
21
  1.45.0 (September 8, 2017)
2
22
 
3
23
  * Bump Rails to 5.1.3 (#857)
data/README.md CHANGED
@@ -80,7 +80,7 @@ And testing gems like:
80
80
  * [Capybara](https://github.com/jnicklas/capybara) and
81
81
  [Capybara WebKit](https://github.com/thoughtbot/capybara-webkit) for
82
82
  integration testing
83
- * [Factory Girl](https://github.com/thoughtbot/factory_girl) for test data
83
+ * [Factory Bot](https://github.com/thoughtbot/factory_bot) for test data
84
84
  * [Formulaic](https://github.com/thoughtbot/formulaic) for integration testing
85
85
  HTML forms
86
86
  * [RSpec](https://github.com/rspec/rspec) for unit testing
data/lib/suspenders.rb CHANGED
@@ -1,9 +1,18 @@
1
- require 'suspenders/version'
2
- require 'suspenders/generators/app_generator'
1
+ require "suspenders/version"
2
+ require "suspenders/generators/app_generator"
3
3
  require "suspenders/generators/enforce_ssl_generator"
4
- require "suspenders/generators/initialize_active_job_generator"
5
- require 'suspenders/generators/static_generator'
6
- require 'suspenders/generators/stylesheet_base_generator'
7
- require 'suspenders/actions'
4
+ require "suspenders/generators/static_generator"
5
+ require "suspenders/generators/stylesheet_base_generator"
6
+ require "suspenders/generators/forms_generator"
7
+ require "suspenders/generators/ci_generator"
8
+ require "suspenders/generators/db_optimizations_generator"
9
+ require "suspenders/generators/factories_generator"
10
+ require "suspenders/generators/lint_generator"
11
+ require "suspenders/generators/jobs_generator"
12
+ require "suspenders/generators/analytics_generator"
13
+ require "suspenders/generators/views_generator"
14
+ require "suspenders/generators/js_driver_generator"
15
+ require "suspenders/generators/testing_generator"
16
+ require "suspenders/actions"
8
17
  require "suspenders/adapters/heroku"
9
- require 'suspenders/app_builder'
18
+ require "suspenders/app_builder"
@@ -15,18 +15,10 @@ module Suspenders
15
15
  end
16
16
 
17
17
  def action_mailer_asset_host(rails_env, host)
18
- config = "config.action_mailer.asset_host = { host: #{host} }"
18
+ config = "config.action_mailer.asset_host = #{host}"
19
19
  configure_environment(rails_env, config)
20
20
  end
21
21
 
22
- def configure_application_file(config)
23
- inject_into_file(
24
- "config/application.rb",
25
- "\n\n #{config}",
26
- before: "\n end"
27
- )
28
- end
29
-
30
22
  def configure_environment(rails_env, config)
31
23
  inject_into_file(
32
24
  "config/environments/#{rails_env}.rb",
@@ -55,23 +55,6 @@ module Suspenders
55
55
  )
56
56
  end
57
57
 
58
- def add_bullet_gem_configuration
59
- config = <<-RUBY
60
- config.after_initialize do
61
- Bullet.enable = true
62
- Bullet.bullet_logger = true
63
- Bullet.rails_logger = true
64
- end
65
-
66
- RUBY
67
-
68
- inject_into_file(
69
- "config/environments/development.rb",
70
- config,
71
- after: "config.action_mailer.raise_delivery_errors = true\n",
72
- )
73
- end
74
-
75
58
  def raise_on_unpermitted_parameters
76
59
  config = <<-RUBY
77
60
  config.action_controller.action_on_unpermitted_parameters = :raise
@@ -93,10 +76,6 @@ module Suspenders
93
76
  run "chmod a+x bin/setup"
94
77
  end
95
78
 
96
- def provide_dev_prime_task
97
- copy_file 'dev.rake', 'lib/tasks/dev.rake'
98
- end
99
-
100
79
  def configure_generators
101
80
  config = <<-RUBY
102
81
 
@@ -115,18 +94,6 @@ module Suspenders
115
94
  inject_into_class 'config/application.rb', 'Application', config
116
95
  end
117
96
 
118
- def set_up_factory_girl_for_rspec
119
- copy_file 'factory_girl_rspec.rb', 'spec/support/factory_girl.rb'
120
- end
121
-
122
- def generate_factories_file
123
- copy_file "factories.rb", "spec/factories.rb"
124
- end
125
-
126
- def set_up_hound
127
- copy_file "hound.yml", ".hound.yml"
128
- end
129
-
130
97
  def configure_smtp
131
98
  copy_file 'smtp.rb', 'config/smtp.rb'
132
99
 
@@ -186,32 +153,6 @@ config.public_file_server.headers = {
186
153
  remove_file "config/initializers/wrap_parameters.rb"
187
154
  end
188
155
 
189
- def create_partials_directory
190
- empty_directory 'app/views/application'
191
- end
192
-
193
- def create_shared_flashes
194
- copy_file "_flashes.html.erb", "app/views/application/_flashes.html.erb"
195
- copy_file "flashes_helper.rb", "app/helpers/flashes_helper.rb"
196
- end
197
-
198
- def create_shared_javascripts
199
- copy_file '_javascript.html.erb', 'app/views/application/_javascript.html.erb'
200
- end
201
-
202
- def create_shared_css_overrides
203
- copy_file(
204
- "_css_overrides.html.erb",
205
- "app/views/application/_css_overrides.html.erb",
206
- )
207
- end
208
-
209
- def create_application_layout
210
- template 'suspenders_layout.html.erb.erb',
211
- 'app/views/layouts/application.html.erb',
212
- force: true
213
- end
214
-
215
156
  def use_postgres_config_template
216
157
  template 'postgresql_database.yml.erb', 'config/database.yml',
217
158
  force: true
@@ -235,54 +176,15 @@ config.public_file_server.headers = {
235
176
  create_file '.ruby-version', "#{Suspenders::RUBY_VERSION}\n"
236
177
  end
237
178
 
238
- def enable_database_cleaner
239
- copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
240
- end
241
-
242
- def provide_shoulda_matchers_config
243
- copy_file(
244
- "shoulda_matchers_config_rspec.rb",
245
- "spec/support/shoulda_matchers.rb"
246
- )
247
- end
248
-
249
- def configure_spec_support_features
250
- empty_directory_with_keep_file 'spec/features'
251
- empty_directory_with_keep_file 'spec/support/features'
252
- end
253
-
254
- def configure_rspec
255
- remove_file "spec/rails_helper.rb"
256
- remove_file "spec/spec_helper.rb"
257
- copy_file "rails_helper.rb", "spec/rails_helper.rb"
258
- copy_file "spec_helper.rb", "spec/spec_helper.rb"
259
- end
260
-
261
- def configure_ci
262
- template "circle.yml.erb", "circle.yml"
263
- end
264
-
265
- def configure_i18n_for_test_environment
266
- copy_file "i18n.rb", "spec/support/i18n.rb"
267
- end
268
-
269
179
  def configure_i18n_for_missing_translations
270
180
  raise_on_missing_translations_in("development")
271
181
  raise_on_missing_translations_in("test")
272
182
  end
273
183
 
274
- def configure_background_jobs_for_rspec
275
- run 'rails g delayed_job:active_record'
276
- end
277
-
278
184
  def configure_action_mailer_in_specs
279
185
  copy_file 'action_mailer.rb', 'spec/support/action_mailer.rb'
280
186
  end
281
187
 
282
- def configure_capybara_webkit
283
- copy_file "capybara_webkit.rb", "spec/support/capybara_webkit.rb"
284
- end
285
-
286
188
  def configure_time_formats
287
189
  remove_file "config/locales/en.yml"
288
190
  template "config_locales_en.yml.erb", "config/locales/en.yml"
@@ -296,15 +198,11 @@ Rack::Timeout.timeout = (ENV["RACK_TIMEOUT"] || 10).to_i
296
198
  append_file "config/environments/production.rb", rack_timeout_config
297
199
  end
298
200
 
299
- def configure_simple_form
300
- bundle_command "exec rails generate simple_form:install"
301
- end
302
-
303
201
  def configure_action_mailer
304
202
  action_mailer_host "development", %{"localhost:3000"}
305
- action_mailer_asset_host "development", %{"localhost:3000"}
203
+ action_mailer_asset_host "development", %{"http://localhost:3000"}
306
204
  action_mailer_host "test", %{"www.example.com"}
307
- action_mailer_asset_host "test", %{"www.example.com"}
205
+ action_mailer_asset_host "test", %{"http://www.example.com"}
308
206
  action_mailer_host "production", %{ENV.fetch("APPLICATION_HOST")}
309
207
  action_mailer_asset_host(
310
208
  "production",
@@ -312,17 +210,6 @@ Rack::Timeout.timeout = (ENV["RACK_TIMEOUT"] || 10).to_i
312
210
  )
313
211
  end
314
212
 
315
- def configure_active_job
316
- configure_application_file(
317
- "config.active_job.queue_adapter = :delayed_job"
318
- )
319
- configure_environment "test", "config.active_job.queue_adapter = :inline"
320
- end
321
-
322
- def generate_rspec
323
- generate 'rspec:install'
324
- end
325
-
326
213
  def replace_default_puma_configuration
327
214
  copy_file "puma.rb", "config/puma.rb", force: true
328
215
  end
@@ -388,11 +275,6 @@ you can deploy to staging and production with:
388
275
  run "hub create #{repo_name}"
389
276
  end
390
277
 
391
- def setup_segment
392
- copy_file '_analytics.html.erb',
393
- 'app/views/application/_analytics.html.erb'
394
- end
395
-
396
278
  def setup_bundler_audit
397
279
  copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake"
398
280
  append_file "Rakefile", %{\ntask default: "bundle:audit"\n}
@@ -0,0 +1,29 @@
1
+ require "rails/generators"
2
+
3
+ module Suspenders
4
+ class AnalyticsGenerator < Rails::Generators::Base
5
+ source_root File.expand_path(
6
+ File.join("..", "..", "..", "templates"),
7
+ File.dirname(__FILE__),
8
+ )
9
+
10
+ def install_partial
11
+ copy_file "_analytics.html.erb",
12
+ "app/views/application/_analytics.html.erb"
13
+ end
14
+
15
+ def render_partial
16
+ if File.exist?(js_partial)
17
+ inject_into_file js_partial,
18
+ %{\n\n<%= render "analytics" %>},
19
+ after: "<%= yield :javascript %>"
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def js_partial
26
+ "app/views/application/_javascript.html.erb"
27
+ end
28
+ end
29
+ end
@@ -43,10 +43,8 @@ module Suspenders
43
43
  def suspenders_customization
44
44
  invoke :customize_gemfile
45
45
  invoke :setup_development_environment
46
- invoke :setup_test_environment
47
46
  invoke :setup_production_environment
48
47
  invoke :setup_secret_token
49
- invoke :create_suspenders_views
50
48
  invoke :configure_app
51
49
  invoke :copy_miscellaneous_files
52
50
  invoke :customize_error_pages
@@ -54,14 +52,13 @@ module Suspenders
54
52
  invoke :remove_routes_comment_lines
55
53
  invoke :setup_dotfiles
56
54
  invoke :setup_database
57
- invoke :create_local_heroku_setup
58
- invoke :create_heroku_apps
59
55
  invoke :create_github_repo
60
- invoke :setup_segment
61
56
  invoke :setup_bundler_audit
62
57
  invoke :setup_spring
63
58
  invoke :generate_default
64
59
  invoke :setup_default_directories
60
+ invoke :create_local_heroku_setup
61
+ invoke :create_heroku_apps
65
62
  invoke :outro
66
63
  end
67
64
 
@@ -69,7 +66,6 @@ module Suspenders
69
66
  build :replace_gemfile, options[:path]
70
67
  build :set_ruby_to_version_being_used
71
68
  bundle_command 'install'
72
- build :configure_simple_form
73
69
  end
74
70
 
75
71
  def setup_database
@@ -87,32 +83,13 @@ module Suspenders
87
83
  build :raise_on_missing_assets_in_test
88
84
  build :raise_on_delivery_errors
89
85
  build :set_test_delivery_method
90
- build :add_bullet_gem_configuration
91
86
  build :raise_on_unpermitted_parameters
92
87
  build :provide_setup_script
93
- build :provide_dev_prime_task
94
88
  build :configure_generators
95
89
  build :configure_i18n_for_missing_translations
96
90
  build :configure_quiet_assets
97
91
  end
98
92
 
99
- def setup_test_environment
100
- say 'Setting up the test environment'
101
- build :set_up_factory_girl_for_rspec
102
- build :generate_factories_file
103
- build :set_up_hound
104
- build :generate_rspec
105
- build :configure_rspec
106
- build :configure_background_jobs_for_rspec
107
- build :enable_database_cleaner
108
- build :provide_shoulda_matchers_config
109
- build :configure_spec_support_features
110
- build :configure_ci
111
- build :configure_i18n_for_test_environment
112
- build :configure_action_mailer_in_specs
113
- build :configure_capybara_webkit
114
- end
115
-
116
93
  def setup_production_environment
117
94
  say 'Setting up the production environment'
118
95
  build :configure_smtp
@@ -127,19 +104,9 @@ module Suspenders
127
104
  build :setup_secret_token
128
105
  end
129
106
 
130
- def create_suspenders_views
131
- say 'Creating suspenders views'
132
- build :create_partials_directory
133
- build :create_shared_flashes
134
- build :create_shared_javascripts
135
- build :create_shared_css_overrides
136
- build :create_application_layout
137
- end
138
-
139
107
  def configure_app
140
108
  say 'Configuring app'
141
109
  build :configure_action_mailer
142
- build :configure_active_job
143
110
  build :configure_time_formats
144
111
  build :setup_default_rake_task
145
112
  build :replace_default_puma_configuration
@@ -175,11 +142,6 @@ module Suspenders
175
142
  end
176
143
  end
177
144
 
178
- def setup_segment
179
- say 'Setting up Segment'
180
- build :setup_segment
181
- end
182
-
183
145
  def setup_dotfiles
184
146
  build :copy_dotfiles
185
147
  end
@@ -218,10 +180,19 @@ module Suspenders
218
180
 
219
181
  def generate_default
220
182
  run("spring stop")
221
- generate("suspenders:initialize_active_job")
222
183
  generate("suspenders:enforce_ssl")
223
184
  generate("suspenders:static")
224
185
  generate("suspenders:stylesheet_base")
186
+ generate("suspenders:testing")
187
+ generate("suspenders:ci")
188
+ generate("suspenders:js_driver")
189
+ generate("suspenders:forms")
190
+ generate("suspenders:db_optimizations")
191
+ generate("suspenders:factories")
192
+ generate("suspenders:lint")
193
+ generate("suspenders:jobs")
194
+ generate("suspenders:analytics")
195
+ generate("suspenders:views")
225
196
  end
226
197
 
227
198
  def outro
@@ -0,0 +1,26 @@
1
+ require "rails/generators"
2
+
3
+ module Suspenders
4
+ class CiGenerator < Rails::Generators::Base
5
+ source_root File.expand_path(
6
+ File.join("..", "..", "..", "templates"),
7
+ File.dirname(__FILE__))
8
+
9
+ def simplecov_test_integration
10
+ inject_into_file "spec/spec_helper.rb", before: 'SimpleCov.start "rails"' do
11
+ <<-RUBY
12
+
13
+ if ENV["CIRCLE_ARTIFACTS"]
14
+ dir = File.join(ENV["CIRCLE_ARTIFACTS"], "coverage")
15
+ SimpleCov.coverage_dir(dir)
16
+ end
17
+
18
+ RUBY
19
+ end
20
+ end
21
+
22
+ def configure_ci
23
+ template "circle.yml.erb", "circle.yml"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ require "rails/generators"
2
+
3
+ module Suspenders
4
+ class DbOptimizationsGenerator < Rails::Generators::Base
5
+ def add_bullet
6
+ gem "bullet", group: %i(development test)
7
+ end
8
+
9
+ def configure_bullet
10
+ inject_into_file(
11
+ "config/environments/development.rb",
12
+ configuration,
13
+ after: "config.action_mailer.raise_delivery_errors = true\n",
14
+ )
15
+ end
16
+
17
+ private
18
+
19
+ def configuration
20
+ <<-RUBY
21
+ config.after_initialize do
22
+ Bullet.enable = true
23
+ Bullet.bullet_logger = true
24
+ Bullet.rails_logger = true
25
+ end
26
+ RUBY
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ require "rails/generators"
2
+
3
+ module Suspenders
4
+ class FactoriesGenerator < Rails::Generators::Base
5
+ source_root File.expand_path(
6
+ File.join("..", "..", "..", "templates"),
7
+ File.dirname(__FILE__),
8
+ )
9
+
10
+ def add_factory_bot
11
+ gem "factory_bot_rails", group: %i(development test)
12
+ end
13
+
14
+ def set_up_factory_bot_for_rspec
15
+ copy_file "factory_bot_rspec.rb", "spec/support/factory_bot.rb"
16
+ end
17
+
18
+ def generate_empty_factories_file
19
+ copy_file "factories.rb", "spec/factories.rb"
20
+ end
21
+
22
+ def provide_dev_prime_task
23
+ copy_file "dev.rake", "lib/tasks/dev.rake"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ require "rails/generators"
2
+
3
+ module Suspenders
4
+ class FormsGenerator < Rails::Generators::Base
5
+ def add_simple_form
6
+ gem "simple_form"
7
+ Bundler.with_clean_env { run "bundle install" }
8
+ end
9
+
10
+ def configure_simple_form
11
+ create_file "config/initializers/simple_form.rb" do
12
+ "SimpleForm.setup {|config|}"
13
+ end
14
+
15
+ generate "simple_form:install", "--force"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,47 @@
1
+ require "rails/generators"
2
+
3
+ module Suspenders
4
+ class JobsGenerator < Rails::Generators::Base
5
+ include Suspenders::Actions
6
+
7
+ source_root(
8
+ File.expand_path(
9
+ File.join("..", "..", "..", "templates"),
10
+ File.dirname(__FILE__),
11
+ ),
12
+ )
13
+
14
+ def add_jobs_gem
15
+ gem "delayed_job_active_record"
16
+ Bundler.with_clean_env { run "bundle install" }
17
+ end
18
+
19
+ def configure_background_jobs_for_rspec
20
+ generate "delayed_job:active_record"
21
+ end
22
+
23
+ def initialize_active_job
24
+ copy_file(
25
+ "active_job.rb",
26
+ "config/initializers/active_job.rb",
27
+ )
28
+ end
29
+
30
+ def configure_active_job
31
+ configure_application_file(
32
+ "config.active_job.queue_adapter = :delayed_job",
33
+ )
34
+ configure_environment "test", "config.active_job.queue_adapter = :inline"
35
+ end
36
+
37
+ private
38
+
39
+ def configure_application_file(config)
40
+ inject_into_file(
41
+ "config/application.rb",
42
+ "\n #{config}",
43
+ before: "\n end",
44
+ )
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,18 @@
1
+ require "rails/generators"
2
+
3
+ module Suspenders
4
+ class JsDriverGenerator < Rails::Generators::Base
5
+ source_root File.expand_path(
6
+ File.join("..", "..", "..", "templates"),
7
+ File.dirname(__FILE__),
8
+ )
9
+
10
+ def add_gems
11
+ gem "capybara-webkit", group: :test
12
+ end
13
+
14
+ def configure_capybara_webkit
15
+ copy_file "capybara_webkit.rb", "spec/support/capybara_webkit.rb"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ require "rails/generators"
2
+
3
+ module Suspenders
4
+ class LintGenerator < Rails::Generators::Base
5
+ source_root File.expand_path(
6
+ File.join("..", "..", "..", "templates"),
7
+ File.dirname(__FILE__),
8
+ )
9
+
10
+ def set_up_hound
11
+ copy_file "hound.yml", ".hound.yml"
12
+ end
13
+ end
14
+ end
@@ -7,7 +7,7 @@ module Suspenders
7
7
  File.dirname(__FILE__))
8
8
 
9
9
  def add_stylesheet_gems
10
- gem "bourbon", "~> 5.0.0.beta.8"
10
+ gem "bourbon", "~> 5.0"
11
11
  gem "neat", "~> 2.1"
12
12
  gem "refills", group: [:development, :test]
13
13
  Bundler.with_clean_env { run "bundle install" }
@@ -0,0 +1,60 @@
1
+ require "rails/generators"
2
+
3
+ module Suspenders
4
+ class TestingGenerator < Rails::Generators::Base
5
+ source_root File.expand_path(
6
+ File.join("..", "..", "..", "templates"),
7
+ File.dirname(__FILE__),
8
+ )
9
+
10
+ def add_testing_gems
11
+ gem "spring-commands-rspec", group: :development
12
+ gem "rspec-rails", "~> 3.6", group: %i(development test)
13
+ gem "shoulda-matchers", group: :test
14
+
15
+ Bundler.with_clean_env { run "bundle install" }
16
+ end
17
+
18
+ def generate_rspec
19
+ generate "rspec:install"
20
+ end
21
+
22
+ def configure_rspec
23
+ remove_file "spec/rails_helper.rb"
24
+ remove_file "spec/spec_helper.rb"
25
+ copy_file "rails_helper.rb", "spec/rails_helper.rb"
26
+ copy_file "spec_helper.rb", "spec/spec_helper.rb"
27
+ end
28
+
29
+ def provide_shoulda_matchers_config
30
+ copy_file(
31
+ "shoulda_matchers_config_rspec.rb",
32
+ "spec/support/shoulda_matchers.rb",
33
+ )
34
+ end
35
+
36
+ def configure_spec_support_features
37
+ empty_directory_with_keep_file "spec/features"
38
+ empty_directory_with_keep_file "spec/support/features"
39
+ end
40
+
41
+ def configure_i18n_for_test_environment
42
+ copy_file "i18n.rb", "spec/support/i18n.rb"
43
+ end
44
+
45
+ def configure_action_mailer_in_specs
46
+ copy_file "action_mailer.rb", "spec/support/action_mailer.rb"
47
+ end
48
+
49
+ private
50
+
51
+ def empty_directory_with_keep_file(destination)
52
+ empty_directory(destination, {})
53
+ keep_file(destination)
54
+ end
55
+
56
+ def keep_file(destination)
57
+ create_file(File.join(destination, ".keep"))
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,35 @@
1
+ require "rails/generators"
2
+
3
+ module Suspenders
4
+ class ViewsGenerator < Rails::Generators::Base
5
+ source_root File.expand_path(
6
+ File.join("..", "..", "..", "templates"),
7
+ File.dirname(__FILE__),
8
+ )
9
+
10
+ def create_partials_directory
11
+ empty_directory "app/views/application"
12
+ end
13
+
14
+ def create_shared_flashes
15
+ copy_file "_flashes.html.erb", "app/views/application/_flashes.html.erb"
16
+ copy_file "flashes_helper.rb", "app/helpers/flashes_helper.rb"
17
+ end
18
+
19
+ def create_shared_javascripts
20
+ copy_file "_javascript.html.erb",
21
+ "app/views/application/_javascript.html.erb"
22
+ end
23
+
24
+ def create_shared_css_overrides
25
+ copy_file "_css_overrides.html.erb",
26
+ "app/views/application/_css_overrides.html.erb"
27
+ end
28
+
29
+ def create_application_layout
30
+ template "suspenders_layout.html.erb.erb",
31
+ "app/views/layouts/application.html.erb",
32
+ force: true
33
+ end
34
+ end
35
+ end
@@ -1,8 +1,8 @@
1
1
  module Suspenders
2
- RAILS_VERSION = "~> 5.1.3".freeze
2
+ RAILS_VERSION = "~> 5.1.4".freeze
3
3
  RUBY_VERSION = IO.
4
4
  read("#{File.dirname(__FILE__)}/../../.ruby-version").
5
5
  strip.
6
6
  freeze
7
- VERSION = "1.45.0".freeze
7
+ VERSION = "1.46.0".freeze
8
8
  end
@@ -169,7 +169,7 @@ RSpec.describe "Suspend a new project with default configuration" do
169
169
  it "sets action mailer default host and asset host" do
170
170
  config_key = 'config\.action_mailer\.asset_host'
171
171
  config_value =
172
- '{ host: ENV\.fetch\("ASSET_HOST", ENV\.fetch\("APPLICATION_HOST"\)\) }'
172
+ %q{ENV\.fetch\("ASSET_HOST", ENV\.fetch\("APPLICATION_HOST"\)\)}
173
173
  expect(production_config).to match(/#{config_key} = #{config_value}/)
174
174
  end
175
175
 
@@ -201,6 +201,14 @@ RSpec.describe "Suspend a new project with default configuration" do
201
201
  )
202
202
  end
203
203
 
204
+ it "configs background jobs for rspec" do
205
+ delayed_job = IO.read("#{project_path}/bin/delayed_job")
206
+
207
+ expect(delayed_job).to match(
208
+ /^require 'delayed\/command'$/,
209
+ )
210
+ end
211
+
204
212
  it "configs bullet gem in development" do
205
213
  expect(development_config).to match /^ +Bullet.enable = true$/
206
214
  expect(development_config).to match /^ +Bullet.bullet_logger = true$/
@@ -14,9 +14,11 @@ module SuspendersTestHelpers
14
14
  Dir.chdir(tmp_path) do
15
15
  Bundler.with_clean_env do
16
16
  add_fakes_to_path
17
- `
18
- #{suspenders_bin} #{APP_NAME} #{arguments}
19
- `
17
+ with_revision_for_honeybadger do
18
+ `
19
+ #{suspenders_bin} #{APP_NAME} #{arguments}
20
+ `
21
+ end
20
22
  Dir.chdir(APP_NAME) do
21
23
  with_env("HOME", tmp_path) do
22
24
  `git add .`
@@ -88,12 +90,23 @@ module SuspendersTestHelpers
88
90
  end
89
91
 
90
92
  def with_env(name, new_value)
93
+ had_key = ENV.has_key?(name)
91
94
  prior = ENV[name]
92
95
  ENV[name] = new_value.to_s
93
96
 
94
97
  yield
95
98
 
96
99
  ensure
97
- ENV[name] = prior
100
+ ENV.delete(name)
101
+
102
+ if had_key
103
+ ENV[name] = prior
104
+ end
105
+ end
106
+
107
+ def with_revision_for_honeybadger
108
+ with_env("HEROKU_SLUG_COMMIT", 1) do
109
+ yield
110
+ end
98
111
  end
99
112
  end
data/suspenders.gemspec CHANGED
@@ -5,6 +5,7 @@ require 'date'
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.required_ruby_version = ">= #{Suspenders::RUBY_VERSION}"
8
+ s.required_rubygems_version = ">= 2.7.4"
8
9
  s.authors = ['thoughtbot']
9
10
  s.date = Date.today.strftime('%Y-%m-%d')
10
11
 
@@ -28,7 +29,6 @@ rush to build something amazing; don't use it if you like missing deadlines.
28
29
  s.version = Suspenders::VERSION
29
30
 
30
31
  s.add_dependency 'bitters', '~> 1.7'
31
- s.add_dependency 'bundler', '~> 1.3'
32
32
  s.add_dependency 'rails', Suspenders::RAILS_VERSION
33
33
 
34
34
  s.add_development_dependency 'rspec', '~> 3.2'
@@ -8,17 +8,15 @@ end
8
8
  ruby "<%= Suspenders::RUBY_VERSION %>"
9
9
 
10
10
  gem "autoprefixer-rails"
11
- gem "delayed_job_active_record"
12
11
  gem "flutie"
13
12
  gem "honeybadger"
14
13
  gem "jquery-rails"
15
- gem "pg"
14
+ gem "pg", "~> 0.18"
16
15
  gem "puma"
17
16
  gem "rack-canonical-host"
18
17
  gem "rails", "<%= Suspenders::RAILS_VERSION %>"
19
18
  gem "recipient_interceptor"
20
19
  gem "sass-rails", "~> 5.0"
21
- gem "simple_form"
22
20
  gem "skylight"
23
21
  gem "sprockets", ">= 3.0.0"
24
22
  gem "suspenders"
@@ -32,27 +30,20 @@ group :development do
32
30
  gem "listen"
33
31
  gem "rack-mini-profiler", require: false
34
32
  gem "spring"
35
- gem "spring-commands-rspec"
36
33
  gem "web-console"
37
34
  end
38
35
 
39
36
  group :development, :test do
40
37
  gem "awesome_print"
41
- gem "bullet"
42
38
  gem "bundler-audit", ">= 0.5.0", require: false
43
39
  gem "dotenv-rails"
44
- gem "factory_girl_rails"
45
40
  gem "pry-byebug"
46
41
  gem "pry-rails"
47
- gem "rspec-rails", "~> 3.6"
48
42
  end
49
43
 
50
44
  group :test do
51
- gem "capybara-webkit"
52
- gem "database_cleaner"
53
45
  gem "formulaic"
54
46
  gem "launchy"
55
- gem "shoulda-matchers"
56
47
  gem "simplecov", require: false
57
48
  gem "timecop"
58
49
  gem "webmock"
@@ -2,8 +2,6 @@
2
2
 
3
3
  <%= yield :javascript %>
4
4
 
5
- <%= render "analytics" %>
6
-
7
5
  <% if Rails.env.test? %>
8
6
  <%= javascript_tag do %>
9
7
  $.fx.off = true;
@@ -1,6 +1,6 @@
1
1
  database:
2
2
  override:
3
- - bin/setup
3
+ - RAILS_ENV=development bin/setup
4
4
  test:
5
5
  override:
6
6
  - COVERAGE=true bin/rake
data/templates/dev.rake CHANGED
@@ -1,10 +1,10 @@
1
1
  if Rails.env.development? || Rails.env.test?
2
- require "factory_girl"
2
+ require "factory_bot"
3
3
 
4
4
  namespace :dev do
5
5
  desc "Sample data for local development environment"
6
6
  task prime: "db:setup" do
7
- include FactoryGirl::Syntax::Methods
7
+ include FactoryBot::Syntax::Methods
8
8
 
9
9
  # create(:user, email: "user@example.com", password: "password")
10
10
  end
@@ -1,2 +1,2 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryBot::Syntax::Methods
3
+ end
@@ -16,7 +16,7 @@ RSpec.configure do |config|
16
16
  config.include Features, type: :feature
17
17
  config.infer_base_class_for_anonymous_controllers = false
18
18
  config.infer_spec_type_from_file_location!
19
- config.use_transactional_fixtures = false
19
+ config.use_transactional_fixtures = true
20
20
  end
21
21
 
22
22
  ActiveRecord::Migration.maintain_test_schema!
@@ -1,11 +1,6 @@
1
1
  if ENV.fetch("COVERAGE", false)
2
2
  require "simplecov"
3
3
 
4
- if ENV["CIRCLE_ARTIFACTS"]
5
- dir = File.join(ENV["CIRCLE_ARTIFACTS"], "coverage")
6
- SimpleCov.coverage_dir(dir)
7
- end
8
-
9
4
  SimpleCov.start "rails"
10
5
  end
11
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suspenders
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.45.0
4
+ version: 1.46.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoughtbot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-08 00:00:00.000000000 Z
11
+ date: 2018-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bitters
@@ -24,34 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.7'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.3'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.3'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rails
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: 5.1.3
33
+ version: 5.1.4
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: 5.1.3
40
+ version: 5.1.4
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -97,11 +83,20 @@ files:
97
83
  - lib/suspenders/actions.rb
98
84
  - lib/suspenders/adapters/heroku.rb
99
85
  - lib/suspenders/app_builder.rb
86
+ - lib/suspenders/generators/analytics_generator.rb
100
87
  - lib/suspenders/generators/app_generator.rb
88
+ - lib/suspenders/generators/ci_generator.rb
89
+ - lib/suspenders/generators/db_optimizations_generator.rb
101
90
  - lib/suspenders/generators/enforce_ssl_generator.rb
102
- - lib/suspenders/generators/initialize_active_job_generator.rb
91
+ - lib/suspenders/generators/factories_generator.rb
92
+ - lib/suspenders/generators/forms_generator.rb
93
+ - lib/suspenders/generators/jobs_generator.rb
94
+ - lib/suspenders/generators/js_driver_generator.rb
95
+ - lib/suspenders/generators/lint_generator.rb
103
96
  - lib/suspenders/generators/static_generator.rb
104
97
  - lib/suspenders/generators/stylesheet_base_generator.rb
98
+ - lib/suspenders/generators/testing_generator.rb
99
+ - lib/suspenders/generators/views_generator.rb
105
100
  - lib/suspenders/version.rb
106
101
  - spec/adapters/heroku_spec.rb
107
102
  - spec/fakes/bin/heroku
@@ -134,13 +129,12 @@ files:
134
129
  - templates/capybara_webkit.rb
135
130
  - templates/circle.yml.erb
136
131
  - templates/config_locales_en.yml.erb
137
- - templates/database_cleaner_rspec.rb
138
132
  - templates/dev.rake
139
133
  - templates/dotfiles/.ctags
140
134
  - templates/dotfiles/.env
141
135
  - templates/errors.rb
142
136
  - templates/factories.rb
143
- - templates/factory_girl_rspec.rb
137
+ - templates/factory_bot_rspec.rb
144
138
  - templates/flashes_helper.rb
145
139
  - templates/hound.yml
146
140
  - templates/i18n.rb
@@ -168,15 +162,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
162
  requirements:
169
163
  - - ">="
170
164
  - !ruby/object:Gem::Version
171
- version: 2.4.1
165
+ version: 2.5.0
172
166
  required_rubygems_version: !ruby/object:Gem::Requirement
173
167
  requirements:
174
168
  - - ">="
175
169
  - !ruby/object:Gem::Version
176
- version: '0'
170
+ version: 2.7.4
177
171
  requirements: []
178
172
  rubyforge_project:
179
- rubygems_version: 2.6.13
173
+ rubygems_version: 2.7.4
180
174
  signing_key:
181
175
  specification_version: 4
182
176
  summary: Generate a Rails app using thoughtbot's best practices.
@@ -1,19 +0,0 @@
1
- require "rails/generators"
2
-
3
- module Suspenders
4
- class InitializeActiveJobGenerator < Rails::Generators::Base
5
- source_root(
6
- File.expand_path(
7
- File.join("..", "..", "..", "templates"),
8
- File.dirname(__FILE__),
9
- ),
10
- )
11
-
12
- def initialize_active_job
13
- copy_file(
14
- "active_job.rb",
15
- "config/initializers/active_job.rb",
16
- )
17
- end
18
- end
19
- end
@@ -1,21 +0,0 @@
1
- RSpec.configure do |config|
2
- config.before(:suite) do
3
- DatabaseCleaner.clean_with(:deletion)
4
- end
5
-
6
- config.before(:each) do
7
- DatabaseCleaner.strategy = :transaction
8
- end
9
-
10
- config.before(:each, js: true) do
11
- DatabaseCleaner.strategy = :deletion
12
- end
13
-
14
- config.before(:each) do
15
- DatabaseCleaner.start
16
- end
17
-
18
- config.after(:each) do
19
- DatabaseCleaner.clean
20
- end
21
- end
@@ -1,3 +0,0 @@
1
- RSpec.configure do |config|
2
- config.include FactoryGirl::Syntax::Methods
3
- end