hoboken 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
  3. data/.github/ISSUE_TEMPLATE/code_change.md +11 -0
  4. data/.github/PULL_REQUEST_TEMPLATE.md +25 -0
  5. data/.gitignore +3 -0
  6. data/.rubocop.yml +13 -5
  7. data/.tool-versions +1 -0
  8. data/CHANGELOG.md +131 -0
  9. data/CODE_OF_CONDUCT.md +8 -0
  10. data/CONTRIBUTING.md +16 -0
  11. data/README.md +10 -14
  12. data/Rakefile +7 -16
  13. data/hoboken.gemspec +18 -8
  14. data/lib/hoboken/add_ons/active_record.rb +142 -0
  15. data/lib/hoboken/add_ons/airbrake.rb +64 -0
  16. data/lib/hoboken/add_ons/heroku.rb +5 -1
  17. data/lib/hoboken/add_ons/internationalization.rb +2 -2
  18. data/lib/hoboken/add_ons/metrics.rb +3 -2
  19. data/lib/hoboken/add_ons/omniauth.rb +9 -8
  20. data/lib/hoboken/add_ons/rubocop.rb +10 -4
  21. data/lib/hoboken/add_ons/sequel.rb +55 -29
  22. data/lib/hoboken/add_ons/sidekiq.rb +137 -0
  23. data/lib/hoboken/add_ons/turnip.rb +109 -0
  24. data/lib/hoboken/add_ons/twbs.rb +5 -35
  25. data/lib/hoboken/add_ons/vcr.rb +54 -0
  26. data/lib/hoboken/generate.rb +18 -10
  27. data/lib/hoboken/templates/Gemfile.erb.tt +13 -3
  28. data/lib/hoboken/templates/README.md.tt +18 -6
  29. data/lib/hoboken/templates/Rakefile.tt +11 -0
  30. data/lib/hoboken/templates/active_record.rake +11 -0
  31. data/lib/hoboken/templates/airbrake.rb.tt +13 -0
  32. data/lib/hoboken/templates/classic.rb.tt +6 -20
  33. data/lib/hoboken/templates/classic_environment.rb.tt +51 -0
  34. data/lib/hoboken/templates/config.ru.tt +2 -4
  35. data/lib/hoboken/templates/console +19 -0
  36. data/lib/hoboken/templates/example_worker.rb.tt +14 -0
  37. data/lib/hoboken/templates/metrics.rake.tt +3 -1
  38. data/lib/hoboken/templates/modular.rb.tt +8 -25
  39. data/lib/hoboken/templates/modular_environment.rb.tt +62 -0
  40. data/lib/hoboken/templates/rspec.rake.tt +7 -3
  41. data/lib/hoboken/templates/rubocop.yml.tt +23 -3
  42. data/lib/hoboken/templates/seeds.rb +12 -0
  43. data/lib/hoboken/templates/server +15 -0
  44. data/lib/hoboken/templates/setup +28 -0
  45. data/lib/hoboken/templates/sidekiq.rb.tt +21 -0
  46. data/lib/hoboken/templates/spec/app_spec.rb.tt +0 -2
  47. data/lib/hoboken/templates/spec/example_worker_spec.rb.tt +16 -0
  48. data/lib/hoboken/templates/spec/rack_matchers.rb.tt +8 -6
  49. data/lib/hoboken/templates/spec/spec_helper.rb.tt +2 -6
  50. data/lib/hoboken/templates/spec/turnip_helper.rb.tt +10 -0
  51. data/lib/hoboken/templates/styles.css.tt +1 -1
  52. data/lib/hoboken/templates/support/rack_test_assertions.rb.tt +5 -3
  53. data/lib/hoboken/templates/test/test_helper.rb.tt +2 -5
  54. data/lib/hoboken/templates/test/unit/example_worker_test.rb.tt +20 -0
  55. data/lib/hoboken/templates/vcr_setup.rb.tt +15 -0
  56. data/lib/hoboken/templates/views/index.erb.tt +1 -1
  57. data/lib/hoboken/templates/views/layout.erb.tt +3 -3
  58. data/lib/hoboken/version.rb +1 -1
  59. data/lib/hoboken.rb +54 -10
  60. data/test/integration/active_record_test.rb +66 -0
  61. data/test/integration/airbrake_test.rb +31 -0
  62. data/test/integration/generate_classic_test.rb +75 -0
  63. data/test/integration/generate_modular_test.rb +83 -0
  64. data/test/integration/github_action_test.rb +13 -0
  65. data/test/integration/heroku_test.rb +14 -0
  66. data/test/integration/internationalization_test.rb +26 -0
  67. data/test/integration/metrics_test.rb +54 -0
  68. data/test/integration/omniauth_test.rb +143 -0
  69. data/test/integration/rubocop_test.rb +39 -0
  70. data/test/integration/sequel_test.rb +64 -0
  71. data/test/integration/sidekiq_test.rb +105 -0
  72. data/test/integration/travis_test.rb +13 -0
  73. data/test/integration/turnip_test.rb +51 -0
  74. data/test/integration/twitter_bootstrap_test.rb +39 -0
  75. data/test/integration/vcr_test.rb +54 -0
  76. data/test/test_helper.rb +21 -10
  77. data/www/Gemfile +4 -0
  78. data/www/README.md +2 -0
  79. data/www/config.rb +11 -0
  80. data/www/source/documentation.html.erb +274 -0
  81. data/www/source/images/hoboken-running.png +0 -0
  82. data/www/source/images/hoboken.png +0 -0
  83. data/www/source/images/sinatra.png +0 -0
  84. data/www/source/index.html.erb +44 -0
  85. data/www/source/javascripts/all.js +1 -0
  86. data/www/source/layouts/layout.erb +38 -0
  87. data/www/source/stylesheets/all.css.scss +116 -0
  88. data/www/source/stylesheets/normalize.css +375 -0
  89. metadata +230 -44
  90. data/lib/hoboken/add_ons/sprockets.rb +0 -99
  91. data/lib/hoboken/templates/console.sh +0 -5
  92. data/lib/hoboken/templates/server.sh +0 -12
  93. data/lib/hoboken/templates/setup.sh +0 -7
  94. data/lib/hoboken/templates/sprockets.rake +0 -39
  95. data/lib/hoboken/templates/sprockets_chain.rb +0 -30
  96. data/lib/hoboken/templates/sprockets_helper.rb +0 -17
  97. data/test/integration/add_on_test.rb +0 -505
  98. data/test/integration/generate_test.rb +0 -203
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'sprockets'
4
-
5
- module Middleware
6
- # Sprockets Rack middleware.
7
- #
8
- class SprocketsChain
9
- attr_reader :app, :prefix, :sprockets
10
-
11
- def initialize(app, prefix)
12
- @app = app
13
- @prefix = prefix
14
- @sprockets = Sprockets::Environment.new
15
- yield sprockets if block_given?
16
- end
17
-
18
- def call(env)
19
- path_info = env['PATH_INFO']
20
- if path_info =~ prefix
21
- env['PATH_INFO'].sub!(prefix, '')
22
- sprockets.call(env)
23
- else
24
- app.call(env)
25
- end
26
- ensure
27
- env['PATH_INFO'] = path_info
28
- end
29
- end
30
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Helpers
4
- # Sprockets view helpers.
5
- #
6
- module Sprockets
7
- def stylesheet_tag(name)
8
- folder = 'production' == ENV['RACK_ENV'] ? 'css' : 'assets'
9
- "<link href='/#{folder}/#{name}.css' rel='stylesheet' type='text/css' />"
10
- end
11
-
12
- def javascript_tag(name)
13
- folder = 'production' == ENV['RACK_ENV'] ? 'js' : 'assets'
14
- "<script type='text/javascript' src='/#{folder}/#{name}.js'></script>"
15
- end
16
- end
17
- end
@@ -1,505 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../test_helper'
4
-
5
- # rubocop:disable Metrics/ClassLength
6
- class AddOnTest < IntegrationTestCase
7
- # rubocop:disable Metrics/MethodLength
8
- def test_metrics_add_on
9
- run_hoboken(:generate) do
10
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
11
- execute("#{bin_path} add:metrics")
12
- assert_file('Gemfile', /flog/, /flay/, /simplecov/)
13
- assert_file('tasks/metrics.rake')
14
-
15
- assert_file('test/test_helper.rb', <<~CODE
16
- require 'simplecov'
17
- SimpleCov.start do
18
- add_filter '/bin/'
19
- add_filter '/config/'
20
- add_filter '/test/'
21
- coverage_dir 'tmp/coverage'
22
- end
23
-
24
- CODE
25
- )
26
-
27
- assert_match(/no offenses detected/, execute('rubocop'))
28
- end
29
- end
30
- # rubocop:enable Metrics/MethodLength
31
-
32
- def test_internationalization_add_on_classic
33
- run_hoboken(:generate) do
34
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
35
- execute("#{bin_path} add:i18n")
36
- assert_file('Gemfile', 'sinatra-r18n')
37
- assert_file('app.rb', "require 'sinatra/r18n'")
38
- assert_file('i18n/en.yml')
39
- assert_match(/no offenses detected/, execute('rubocop'))
40
- end
41
- end
42
-
43
- def test_internationalization_add_on_modular
44
- run_hoboken(:generate, type: :modular) do
45
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
46
- execute("#{bin_path} add:i18n")
47
- assert_file('Gemfile', 'sinatra-r18n')
48
- assert_file('app.rb', "require 'sinatra/r18n'", 'register Sinatra::R18n')
49
- assert_file('i18n/en.yml')
50
- assert_match(/no offenses detected/, execute('rubocop'))
51
- end
52
- end
53
-
54
- def test_heroku_add_on
55
- run_hoboken(:generate) do
56
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
57
- execute("#{bin_path} add:heroku")
58
- assert_file('.slugignore')
59
- assert_file('config.ru', /\$stdout.sync = true/)
60
- assert_match(/no offenses detected/, execute('rubocop'))
61
- end
62
- end
63
-
64
- # rubocop:disable Metrics/MethodLength
65
- # rubocop:disable Metrics/AbcSize
66
- def test_sprockets_add_on_classic
67
- run_hoboken(:generate) do
68
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
69
- execute("#{bin_path} add:sprockets")
70
- assert_file('assets/styles.scss')
71
- assert_file('assets/app.js')
72
- assert_file('Gemfile', 'sassc', 'sprockets', 'uglifier', 'yui-compressor')
73
- assert_file('tasks/sprockets.rake')
74
- assert_file('middleware/sprockets_chain.rb')
75
- assert_file('helpers/sprockets.rb')
76
-
77
- assert_file('app.rb', <<CODE
78
- require File.expand_path('middleware/sprockets_chain', settings.root)
79
- use Middleware::SprocketsChain, %r{/assets} do |env|
80
- %w[assets vendor].each do |f|
81
- env.append_path File.expand_path("../\#{f}", __FILE__)
82
- end
83
- end
84
- CODE
85
- )
86
-
87
- assert_file('app.rb', /helpers Helpers::Sprockets/)
88
- assert_file('views/layout.erb', <<CODE
89
- <%== stylesheet_tag :styles %>
90
- <%== javascript_tag :app %>
91
- CODE
92
- )
93
-
94
- assert_match(
95
- /successfully compiled css assets/,
96
- execute('rake assets:precompile_css')
97
- )
98
-
99
- assert_match(
100
- /successfully compiled javascript assets/,
101
- execute('rake assets:precompile_js')
102
- )
103
-
104
- assert_match(/no offenses detected/, execute('rubocop'))
105
- end
106
- end
107
- # rubocop:enable Metrics/MethodLength
108
- # rubocop:enable Metrics/AbcSize
109
-
110
- # rubocop:disable Metrics/MethodLength
111
- # rubocop:disable Metrics/AbcSize
112
- def test_sprockets_add_on_modular
113
- run_hoboken(:generate, type: :modular) do
114
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
115
- execute("#{bin_path} add:sprockets")
116
- assert_file('assets/styles.scss')
117
- assert_file('assets/app.js')
118
- assert_file('Gemfile', 'sassc', 'sprockets', 'uglifier', 'yui-compressor')
119
- assert_file('tasks/sprockets.rake')
120
- assert_file('middleware/sprockets_chain.rb')
121
- assert_file('helpers/sprockets.rb')
122
-
123
- assert_file('app.rb', <<CODE
124
- configure :development do
125
- require File.expand_path('middleware/sprockets_chain', settings.root)
126
- use Middleware::SprocketsChain, %r{/assets} do |env|
127
- %w[assets vendor].each do |f|
128
- env.append_path File.expand_path("../\#{f}", __FILE__)
129
- end
130
- end
131
- CODE
132
- )
133
-
134
- assert_file('views/layout.erb', <<CODE
135
- <%== stylesheet_tag :styles %>
136
- <%== javascript_tag :app %>
137
- CODE
138
- )
139
-
140
- assert_match(
141
- /successfully compiled css assets/,
142
- execute('rake assets:precompile_css')
143
- )
144
-
145
- assert_match(
146
- /successfully compiled javascript assets/,
147
- execute('rake assets:precompile_js')
148
- )
149
-
150
- assert_match(/no offenses detected/, execute('rubocop'))
151
- end
152
- end
153
- # rubocop:enable Metrics/MethodLength
154
- # rubocop:enable Metrics/AbcSize
155
-
156
- def test_travis_add_on
157
- run_hoboken(:generate) do
158
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
159
- execute("#{bin_path} add:travis")
160
- assert_file('.travis.yml', 'language: ruby')
161
- end
162
- end
163
-
164
- # rubocop:disable Metrics/MethodLength
165
- def test_sequel_add_on
166
- run_hoboken(:generate) do
167
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
168
- execute("#{bin_path} add:sequel")
169
- assert_file('Gemfile', 'sequel', 'sqlite3')
170
- assert_file('tasks/sequel.rake')
171
-
172
- assert_file('config/db.rb')
173
-
174
- assert_file(
175
- 'test/test_helper.rb',
176
- %r{ENV\['DATABASE_URL'\] = 'sqlite://db/test\.db'}
177
- )
178
-
179
- assert_file('test/test_helper.rb', /require 'sequel'/)
180
- assert_file('test/test_helper.rb', <<~CODE
181
- module Test
182
- module Database
183
- class TestCase < Test::Unit::TestCase
184
- def run(*args, &block)
185
- result = nil
186
- DB.transaction(rollback: :always) { result = super }
187
- result
188
- end
189
- end
190
- end
191
- end
192
- CODE
193
- )
194
-
195
- result = execute('rake test:all')
196
- assert_match(/1 tests, 3 assertions, 0 failures, 0 errors/, result)
197
- assert_match(/no offenses detected/, execute('rubocop'))
198
- end
199
- end
200
- # rubocop:enable Metrics/MethodLength
201
-
202
- # rubocop:disable Metrics/MethodLength
203
- def test_sequel_add_on_with_rspec
204
- run_hoboken(:generate, test_framework: 'rspec') do
205
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
206
- execute("#{bin_path} add:sequel")
207
-
208
- assert_file(
209
- 'spec/spec_helper.rb',
210
- %r{ENV\['DATABASE_URL'\] = 'sqlite://db/test\.db'}
211
- )
212
-
213
- assert_file('spec/spec_helper.rb', <<-CODE
214
- config.around(:example, rack: true) do |example|
215
- DB.transaction(rollback: :always) { example.run }
216
- end
217
-
218
- config.around(:example, database: true) do |example|
219
- DB.transaction(rollback: :always) { example.run }
220
- end
221
-
222
- CODE
223
- )
224
-
225
- result = execute('rake spec')
226
- assert_match(/3 examples, 0 failures/, result)
227
- assert_match(/no offenses detected/, execute('rubocop'))
228
- end
229
- end
230
- # rubocop:enable Metrics/MethodLength
231
-
232
- # rubocop:disable Metrics/MethodLength
233
- def test_omniauth_add_on
234
- run_hoboken(:generate) do
235
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
236
- execute("(echo 'twitter' && echo '0.0.1') | #{bin_path} add:omniauth")
237
- assert_file('Gemfile', 'omniauth-twitter')
238
- assert_file('app.rb', /require 'omniauth-twitter'/)
239
- assert_file('app.rb', %r{require 'sinatra/json'})
240
- assert_file('app.rb', <<CODE
241
- use OmniAuth::Builder do
242
- provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
243
- end
244
- CODE
245
- )
246
-
247
- assert_file('app.rb', <<~CODE
248
- get '/login' do
249
- '<a href="/auth/twitter">Login</a>'
250
- end
251
-
252
- get '/auth/:provider/callback' do
253
- # TODO: Insert real authentication logic...
254
- json request.env['omniauth.auth']
255
- end
256
-
257
- get '/auth/failure' do
258
- # TODO: Insert real error handling logic...
259
- halt 401, params[:message]
260
- end
261
- CODE
262
- )
263
-
264
- assert_match(/no offenses detected/, execute('rubocop'))
265
- end
266
- end
267
- # rubocop:enable Metrics/MethodLength
268
-
269
- # rubocop:disable Metrics/MethodLength
270
- def test_omniauth_add_on_tests
271
- run_hoboken(:generate) do
272
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
273
- execute("(echo 'twitter' && echo '0.0.1') | #{bin_path} add:omniauth")
274
- assert_file('test/unit/app_test.rb', <<-CODE
275
- setup do
276
- OmniAuth.config.test_mode = true
277
- end
278
-
279
- test 'GET /login' do
280
- get '/login'
281
- assert_equal('<a href="/auth/twitter">Login</a>', last_response.body)
282
- end
283
-
284
- test 'GET /auth/twitter/callback' do
285
- auth_hash = {
286
- provider: 'twitter',
287
- uid: '123545',
288
- info: {
289
- name: 'John Doe'
290
- }
291
- }
292
-
293
- OmniAuth.config.mock_auth[:twitter] = auth_hash
294
- get '/auth/twitter/callback'
295
- assert_equal(MultiJson.encode(auth_hash), last_response.body)
296
- end
297
-
298
- test 'GET /auth/failure' do
299
- OmniAuth.config.mock_auth[:twitter] = :invalid_credentials
300
- get '/auth/failure'
301
- assert_response :not_authorized
302
- end
303
-
304
- CODE
305
- )
306
- end
307
- end
308
- # rubocop:enable Metrics/MethodLength
309
-
310
- def test_omniauth_add_on_tests_pass
311
- run_hoboken(:generate) do
312
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
313
- execute("(echo 'twitter' && echo '0.0.1') | #{bin_path} add:omniauth")
314
- execute('bundle install')
315
- result = execute('rake test:all')
316
- assert_match(/4 tests, 6 assertions, 0 failures, 0 errors/, result)
317
- end
318
- end
319
-
320
- # rubocop:disable Metrics/MethodLength
321
- def test_omniauth_add_on_specs
322
- run_hoboken(:generate, test_framework: 'rspec') do
323
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
324
- execute("(echo 'twitter' && echo '0.0.1') | #{bin_path} add:omniauth")
325
- assert_file(
326
- 'spec/app_spec.rb',
327
- <<~CODE
328
- # rubocop:disable RSpec/DescribeClass
329
- RSpec.describe 'omniauth', rack: true do
330
- before(:each) { OmniAuth.config.test_mode = true }
331
-
332
- describe 'GET /login' do
333
- before(:each) { get '/login' }
334
-
335
- it { expect(last_response).to have_http_status(:ok) }
336
- it { expect(last_response).to have_content_type(:html) }
337
-
338
- it 'renders a template with a login link' do
339
- twitter_link = '<a href="/auth/twitter">Login</a>'
340
- expect(last_response.body).to include(twitter_link)
341
- end
342
- end
343
-
344
- describe 'GET /auth/twitter/callback' do
345
- let(:auth_hash) do
346
- {
347
- provider: 'twitter',
348
- uid: '123545',
349
- info: {
350
- name: 'John Doe'
351
- }
352
- }
353
- end
354
-
355
- before(:each) do
356
- OmniAuth.config.mock_auth[:twitter] = auth_hash
357
- get '/auth/twitter/callback'
358
- end
359
-
360
- it { expect(last_response).to have_http_status(:ok) }
361
- it { expect(last_response).to have_content_type(:json) }
362
-
363
- it 'renders the auth hash result' do
364
- expect(last_response.body).to eq(JSON.generate(auth_hash))
365
- end
366
- end
367
-
368
- describe 'GET /auth/failure' do
369
- before(:each) do
370
- OmniAuth.config.mock_auth[:twitter] = :invalid_credentials
371
- get '/auth/failure'
372
- end
373
-
374
- it { expect(last_response).to have_http_status(:not_authorized) }
375
- end
376
- end
377
- # rubocop:enable RSpec/DescribeClass
378
- CODE
379
- )
380
- end
381
- end
382
- # rubocop:enable Metrics/MethodLength
383
-
384
- def test_omniauth_add_on_specs_pass
385
- run_hoboken(:generate, test_framework: 'rspec') do
386
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
387
- execute("(echo 'twitter' && echo '0.0.1') | #{bin_path} add:omniauth")
388
- execute('bundle install')
389
- result = execute('rake spec')
390
- assert_match(/10 examples, 0 failures/, result)
391
- end
392
- end
393
-
394
- def test_rubocop_add_on
395
- run_hoboken(:generate) do
396
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
397
- execute("#{bin_path} add:rubocop")
398
- assert_file('Gemfile', /rubocop/, /rubocop-rake/)
399
- assert_file_does_not_have_content 'Gemfile', /rubocop-rspec/
400
- assert_file('tasks/rubocop.rake', %r{rubocop/rake_task}, /RuboCop::RakeTask\.new/)
401
- assert_file('Rakefile', /task ci: \['test:all', 'rubocop'\]/)
402
-
403
- assert_file('.rubocop.yml', '- rubocop-rake')
404
- assert_file('.rubocop.yml', "TargetRubyVersion: #{RUBY_VERSION}")
405
-
406
- assert_match(/no offenses detected/, execute('rubocop'))
407
- end
408
- end
409
-
410
- def test_rubocop_with_rspec_add_on
411
- run_hoboken(:generate, test_framework: 'rspec') do
412
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
413
- execute("#{bin_path} add:rubocop")
414
- assert_file('Gemfile', /rubocop/, /rubocop-rspec/)
415
- assert_file('tasks/rubocop.rake', %r{rubocop/rake_task}, /RuboCop::RakeTask\.new/)
416
- assert_file('Rakefile', /task ci: .*spec rubocop/)
417
-
418
- assert_file('.rubocop.yml', '- rubocop-rspec')
419
-
420
- assert_match(/no offenses detected/, execute('rubocop'))
421
- end
422
- end
423
-
424
- def test_github_action_add_on
425
- run_hoboken(:generate) do
426
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
427
- execute("#{bin_path} add:github_action")
428
- assert_file('.github/workflows/ruby.yml')
429
- assert_match(/no offenses detected/, execute('rubocop'))
430
- end
431
- end
432
-
433
- # rubocop:disable Metrics/MethodLength
434
- # rubocop:disable Metrics/AbcSize
435
- def test_twitter_bootstrap_add_on_classic
436
- run_hoboken(:generate) do
437
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
438
- execute("#{bin_path} add:sprockets")
439
- result = execute("#{bin_path} add:twbs")
440
- assert_match(/Gemfile updated/, result)
441
-
442
- assert_file('Gemfile', /bootstrap/)
443
- assert_file('app.rb', /require 'bootstrap'/)
444
- assert_file('assets/styles.scss', /@import "bootstrap"/)
445
- assert_file('assets/app.js', /require popper/, /require bootstrap-sprockets/)
446
- assert_file('tasks/sprockets.rake', /require 'bootstrap'/)
447
- assert_file_does_not_have_content('views/layout.erb', /normalize/)
448
-
449
- assert_match(
450
- /successfully compiled css assets/,
451
- execute('rake assets:precompile_css')
452
- )
453
-
454
- assert_match(
455
- /successfully compiled javascript assets/,
456
- execute('rake assets:precompile_js')
457
- )
458
-
459
- assert_match(/no offenses detected/, execute('rubocop'))
460
- end
461
- end
462
- # rubocop:enable Metrics/MethodLength
463
- # rubocop:enable Metrics/AbcSize
464
-
465
- # rubocop:disable Metrics/MethodLength
466
- # rubocop:disable Metrics/AbcSize
467
- def test_twitter_bootstrap_add_on_modular
468
- run_hoboken(:generate, type: :modular) do
469
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
470
- execute("#{bin_path} add:sprockets")
471
- result = execute("#{bin_path} add:twbs")
472
- assert_match(/Gemfile updated/, result)
473
-
474
- assert_file('Gemfile', /bootstrap/)
475
- assert_file('app.rb', /require 'bootstrap'/)
476
- assert_file('assets/styles.scss', /@import "bootstrap"/)
477
- assert_file('assets/app.js', /require popper/, /require bootstrap-sprockets/)
478
- assert_file('tasks/sprockets.rake', /require 'bootstrap'/)
479
- assert_file_does_not_have_content('views/layout.erb', /normalize/)
480
-
481
- assert_match(
482
- /successfully compiled css assets/,
483
- execute('rake assets:precompile_css')
484
- )
485
-
486
- assert_match(
487
- /successfully compiled javascript assets/,
488
- execute('rake assets:precompile_js')
489
- )
490
-
491
- assert_match(/no offenses detected/, execute('rubocop'))
492
- end
493
- end
494
- # rubocop:enable Metrics/MethodLength
495
- # rubocop:enable Metrics/AbcSize
496
-
497
- def test_twitter_bootstrap_add_on_without_sprockets
498
- run_hoboken(:generate) do
499
- bin_path = File.expand_path('../../bin/hoboken', __dir__)
500
- result = execute("#{bin_path} add:twbs")
501
- assert_match(/Sprockets is required/, result)
502
- end
503
- end
504
- end
505
- # rubocop:enable Metrics/ClassLength