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
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test_helper'
4
+
5
+ class MetricsTest < IntegrationTestCase
6
+ # rubocop:disable Metrics/MethodLength
7
+ def test_metrics_add_on_with_test_unit
8
+ run_hoboken(:generate) do
9
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
10
+ execute("#{bin_path} add:metrics")
11
+
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 '/db/migrate/'
21
+ add_filter '/test/'
22
+ coverage_dir 'tmp/coverage'
23
+ end
24
+
25
+ CODE
26
+ )
27
+ end
28
+ end
29
+ # rubocop:enable Metrics/MethodLength
30
+
31
+ # rubocop:disable Metrics/MethodLength
32
+ def test_metrics_add_on_with_rspec
33
+ run_hoboken(:generate, test_framework: 'rspec') do
34
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
35
+ execute("#{bin_path} add:metrics")
36
+ assert_file('Gemfile', /flog/, /flay/, /simplecov/)
37
+ assert_file('tasks/metrics.rake')
38
+
39
+ assert_file('spec/spec_helper.rb', <<~CODE
40
+ require 'simplecov'
41
+ SimpleCov.start do
42
+ add_filter '/bin/'
43
+ add_filter '/config/'
44
+ add_filter '/db/migrate/'
45
+ add_filter '/spec/'
46
+ coverage_dir 'tmp/coverage'
47
+ end
48
+
49
+ CODE
50
+ )
51
+ end
52
+ end
53
+ # rubocop:enable Metrics/MethodLength
54
+ end
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test_helper'
4
+
5
+ class OmniauthTest < IntegrationTestCase
6
+ # rubocop:disable Metrics/MethodLength
7
+ def test_omniauth_add_on
8
+ run_hoboken(:generate) do
9
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
10
+ execute("(echo 'twitter' && echo '0.0.1') | #{bin_path} add:omniauth")
11
+ assert_file('Gemfile', 'omniauth-twitter')
12
+ assert_file('app.rb', /require 'omniauth-twitter'/)
13
+ assert_file('app.rb', %r{require 'sinatra/json'})
14
+ assert_file('config/environment.rb', <<CODE
15
+ use OmniAuth::Builder do
16
+ provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
17
+ end
18
+ CODE
19
+ )
20
+
21
+ assert_file('app.rb', <<~CODE
22
+ get '/login' do
23
+ '<a href="/auth/twitter">Login</a>'
24
+ end
25
+
26
+ get '/auth/:provider/callback' do
27
+ # TODO: Insert real authentication logic...
28
+ json request.env['omniauth.auth']
29
+ end
30
+
31
+ get '/auth/failure' do
32
+ # TODO: Insert real error handling logic...
33
+ halt 401, params[:message]
34
+ end
35
+ CODE
36
+ )
37
+ end
38
+ end
39
+ # rubocop:enable Metrics/MethodLength
40
+
41
+ # rubocop:disable Metrics/MethodLength
42
+ def test_omniauth_add_on_tests
43
+ run_hoboken(:generate) do
44
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
45
+ execute("(echo 'twitter' && echo '0.0.1') | #{bin_path} add:omniauth")
46
+ assert_file('test/unit/app_test.rb', <<-CODE
47
+ setup do
48
+ OmniAuth.config.test_mode = true
49
+ end
50
+
51
+ test 'GET /login' do
52
+ get '/login'
53
+ assert_equal('<a href="/auth/twitter">Login</a>', last_response.body)
54
+ end
55
+
56
+ test 'GET /auth/twitter/callback' do
57
+ auth_hash = {
58
+ provider: 'twitter',
59
+ uid: '123545',
60
+ info: {
61
+ name: 'John Doe'
62
+ }
63
+ }
64
+
65
+ OmniAuth.config.mock_auth[:twitter] = auth_hash
66
+ get '/auth/twitter/callback'
67
+ assert_equal(MultiJson.encode(auth_hash), last_response.body)
68
+ end
69
+
70
+ test 'GET /auth/failure' do
71
+ OmniAuth.config.mock_auth[:twitter] = :invalid_credentials
72
+ get '/auth/failure'
73
+ assert_response :not_authorized
74
+ end
75
+
76
+ CODE
77
+ )
78
+ end
79
+ end
80
+ # rubocop:enable Metrics/MethodLength
81
+
82
+ # rubocop:disable Metrics/MethodLength
83
+ def test_omniauth_add_on_specs
84
+ run_hoboken(:generate, test_framework: 'rspec') do
85
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
86
+ execute("(echo 'twitter' && echo '0.0.1') | #{bin_path} add:omniauth")
87
+ assert_file(
88
+ 'spec/app_spec.rb',
89
+ <<~CODE
90
+ RSpec.describe 'omniauth', rack: true do
91
+ before { OmniAuth.config.test_mode = true }
92
+
93
+ describe 'GET /login' do
94
+ before { get '/login' }
95
+
96
+ it { expect(last_response).to have_http_status(:ok) }
97
+ it { expect(last_response).to have_content_type(:html) }
98
+
99
+ it 'renders a template with a login link' do
100
+ twitter_link = '<a href="/auth/twitter">Login</a>'
101
+ expect(last_response.body).to include(twitter_link)
102
+ end
103
+ end
104
+
105
+ describe 'GET /auth/twitter/callback' do
106
+ let(:auth_hash) do
107
+ {
108
+ provider: 'twitter',
109
+ uid: '123545',
110
+ info: {
111
+ name: 'John Doe'
112
+ }
113
+ }
114
+ end
115
+
116
+ before do
117
+ OmniAuth.config.mock_auth[:twitter] = auth_hash
118
+ get '/auth/twitter/callback'
119
+ end
120
+
121
+ it { expect(last_response).to have_http_status(:ok) }
122
+ it { expect(last_response).to have_content_type(:json) }
123
+
124
+ it 'renders the auth hash result' do
125
+ expect(last_response.body).to eq(JSON.generate(auth_hash))
126
+ end
127
+ end
128
+
129
+ describe 'GET /auth/failure' do
130
+ before do
131
+ OmniAuth.config.mock_auth[:twitter] = :invalid_credentials
132
+ get '/auth/failure'
133
+ end
134
+
135
+ it { expect(last_response).to have_http_status(:not_authorized) }
136
+ end
137
+ end
138
+ CODE
139
+ )
140
+ end
141
+ end
142
+ # rubocop:enable Metrics/MethodLength
143
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test_helper'
4
+
5
+ class RubocopTest < IntegrationTestCase
6
+ def test_rubocop_add_on
7
+ run_hoboken(:generate, run_tests: false) do
8
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
9
+ execute("#{bin_path} add:rubocop")
10
+ assert_file('Gemfile', /rubocop/, /rubocop-rake/, /rubocop-performance/)
11
+ assert_file_does_not_have_content 'Gemfile', /rubocop-rspec/
12
+ assert_file('tasks/rubocop.rake', %r{rubocop/rake_task}, /RuboCop::RakeTask\.new/)
13
+ assert_file('Rakefile', /task ci: \['test:all', 'rubocop'\]/)
14
+ assert_file('.rubocop.yml', '- rubocop-rake')
15
+ assert_file('.rubocop.yml', "TargetRubyVersion: #{RUBY_VERSION}")
16
+ end
17
+ end
18
+
19
+ def test_rubocop_with_rspec_add_on
20
+ run_hoboken(:generate, run_tests: false, test_framework: 'rspec') do
21
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
22
+ execute("#{bin_path} add:rubocop")
23
+ assert_file('Gemfile', /rubocop/, /rubocop-rspec/)
24
+ assert_file('tasks/rubocop.rake', %r{rubocop/rake_task}, /RuboCop::RakeTask\.new/)
25
+ assert_file('Rakefile', /task ci: .*spec rubocop/)
26
+ assert_file('.rubocop.yml', '- rubocop-rspec')
27
+ end
28
+ end
29
+
30
+ def test_rubocop_with_sequel_add_on
31
+ run_hoboken(:generate, run_tests: false) do
32
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
33
+ execute("#{bin_path} add:sequel")
34
+ execute("#{bin_path} add:rubocop")
35
+ assert_file('Gemfile', /rubocop/, /rubocop-sequel/)
36
+ assert_file('.rubocop.yml', '- rubocop-sequel')
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test_helper'
4
+
5
+ class SequelTest < IntegrationTestCase
6
+ # rubocop:disable Metrics/MethodLength
7
+ def test_sequel_add_on
8
+ run_hoboken(:generate) do
9
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
10
+ execute("#{bin_path} add:sequel")
11
+ execute('echo "DATABASE_URL=sqlite://db/development.db" > .env')
12
+ assert_file('Gemfile', 'sequel', 'sqlite3')
13
+ assert_file('tasks/sequel.rake')
14
+ assert_file('config/db.rb')
15
+
16
+ assert_file(
17
+ 'test/test_helper.rb',
18
+ %r{ENV\['DATABASE_URL'\] = 'sqlite://db/test\.db'}
19
+ )
20
+
21
+ assert_file('test/test_helper.rb', /require 'sequel'/)
22
+ assert_file('test/test_helper.rb', <<-CODE
23
+ def run(*args, &block)
24
+ result = nil
25
+ DB.transaction(rollback: :always) { result = super }
26
+ result
27
+ end
28
+ CODE
29
+ )
30
+ end
31
+ end
32
+ # rubocop:enable Metrics/MethodLength
33
+
34
+ def test_sequel_add_on_with_rspec
35
+ run_hoboken(:generate, test_framework: 'rspec') do
36
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
37
+ execute("#{bin_path} add:sequel")
38
+
39
+ assert_file(
40
+ 'spec/spec_helper.rb',
41
+ %r{ENV\['DATABASE_URL'\] = 'sqlite://db/test\.db'}
42
+ )
43
+
44
+ assert_file('spec/spec_helper.rb', <<-CODE
45
+ config.around do |example|
46
+ DB.transaction(rollback: :always) { example.run }
47
+ end
48
+
49
+ CODE
50
+ )
51
+ end
52
+ end
53
+
54
+ def test_sequel_add_on_with_rubocop
55
+ run_hoboken(:generate) do
56
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
57
+ execute("#{bin_path} add:rubocop")
58
+ execute("#{bin_path} add:sequel")
59
+ execute('echo "DATABASE_URL=sqlite://db/development.db" > .env')
60
+ assert_file('Gemfile', /rubocop-sequel/)
61
+ assert_file('.rubocop.yml', /- rubocop-sequel/)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test_helper'
4
+
5
+ class SidekiqTest < IntegrationTestCase
6
+ # rubocop:disable Metrics/MethodLength
7
+ def test_sidekiq_add_on_with_classic_and_test_unit
8
+ run_hoboken(:generate) do
9
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
10
+ execute("#{bin_path} add:sidekiq")
11
+ assert_file('Gemfile', 'sidekiq')
12
+ assert_file('config.ru', "require 'sidekiq/web'")
13
+
14
+ assert_file('config.ru', <<~CODE
15
+ if 'production' == ENV.fetch('RACK_ENV', 'production')
16
+ Sidekiq::Web.use Rack::Auth::Basic do |username, password|
17
+ [username, password] == [ENV['SIDEKIQ_USERNAME'], ENV['SIDEKIQ_PASSWORD']]
18
+ end
19
+ end
20
+
21
+ Sidekiq::Web.use Rack::Session::Cookie, secret: ENV['SESSION_SECRET']
22
+ run Rack::URLMap.new('/' => Sinatra::Application, '/sidekiq' => Sidekiq::Web)
23
+ CODE
24
+ )
25
+
26
+ assert_file('config/sidekiq.rb')
27
+ assert_file('workers/example_worker.rb')
28
+ assert_file('test/unit/example_worker_test.rb')
29
+ end
30
+ end
31
+ # rubocop:enable Metrics/MethodLength
32
+
33
+ def test_sidekiq_add_on_with_classic_and_rspec
34
+ run_hoboken(:generate, test_framework: 'rspec') do
35
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
36
+ execute("#{bin_path} add:sidekiq")
37
+ assert_file('workers/example_worker.rb')
38
+ assert_file('spec/spec_helper.rb', <<CODE
39
+ config.before(:each, sidekiq: true) do
40
+ Sidekiq::Worker.clear_all
41
+ end
42
+ CODE
43
+ )
44
+
45
+ assert_file('spec/example_worker_spec.rb')
46
+ end
47
+ end
48
+
49
+ # rubocop:disable Metrics/MethodLength
50
+ def test_sidekiq_add_on_with_modular_and_test_unit
51
+ run_hoboken(:generate, type: :modular) do
52
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
53
+ execute("#{bin_path} add:sidekiq")
54
+ assert_file('Gemfile', 'sidekiq')
55
+ assert_file('config.ru', "require 'sidekiq/web'")
56
+
57
+ assert_file('config.ru', <<~CODE
58
+ if 'production' == ENV.fetch('RACK_ENV', 'production')
59
+ Sidekiq::Web.use Rack::Auth::Basic do |username, password|
60
+ [username, password] == [ENV['SIDEKIQ_USERNAME'], ENV['SIDEKIQ_PASSWORD']]
61
+ end
62
+ end
63
+
64
+ Sidekiq::Web.use Rack::Session::Cookie, secret: ENV['SESSION_SECRET']
65
+ run Rack::URLMap.new('/' => Sample::App, '/sidekiq' => Sidekiq::Web)
66
+ CODE
67
+ )
68
+
69
+ assert_file('config/sidekiq.rb')
70
+ assert_file('workers/example_worker.rb')
71
+ assert_file('test/unit/example_worker_test.rb')
72
+ end
73
+ end
74
+ # rubocop:enable Metrics/MethodLength
75
+
76
+ # rubocop:disable Metrics/MethodLength
77
+ def test_sidekiq_add_on_with_modular_and_rspec
78
+ run_hoboken(:generate, type: :modular, test_framework: 'rspec') do
79
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
80
+ execute("#{bin_path} add:sidekiq")
81
+ assert_file('workers/example_worker.rb')
82
+ assert_file('spec/spec_helper.rb', <<CODE
83
+ config.before(:each, sidekiq: true) do
84
+ Sidekiq::Worker.clear_all
85
+ end
86
+ CODE
87
+ )
88
+
89
+ assert_file('config.ru', <<~CODE
90
+ if 'production' == ENV.fetch('RACK_ENV', 'production')
91
+ Sidekiq::Web.use Rack::Auth::Basic do |username, password|
92
+ [username, password] == [ENV['SIDEKIQ_USERNAME'], ENV['SIDEKIQ_PASSWORD']]
93
+ end
94
+ end
95
+
96
+ Sidekiq::Web.use Rack::Session::Cookie, secret: ENV['SESSION_SECRET']
97
+ run Rack::URLMap.new('/' => Sample::App, '/sidekiq' => Sidekiq::Web)
98
+ CODE
99
+ )
100
+
101
+ assert_file('spec/example_worker_spec.rb')
102
+ end
103
+ end
104
+ # rubocop:enable Metrics/MethodLength
105
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test_helper'
4
+
5
+ class TravisTest < IntegrationTestCase
6
+ def test_travis_add_on
7
+ run_hoboken(:generate, run_tests: false, rubocop: false) do
8
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
9
+ execute("#{bin_path} add:travis")
10
+ assert_file('.travis.yml', 'language: ruby')
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test_helper'
4
+
5
+ class TurnipTest < IntegrationTestCase
6
+ def test_turnip_add_on_classic
7
+ run_hoboken(:generate, test_framework: 'rspec') do
8
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
9
+ result = execute("#{bin_path} add:turnip")
10
+ assert_match(/Gemfile updated/, result)
11
+
12
+ assert_file('Gemfile', /turnip/)
13
+ assert_file('Rakefile', /task ci: %w\[spec turnip\]/)
14
+ assert_file('Rakefile', /task default: %w\[spec turnip\]/)
15
+ assert_file('spec/features/example.feature')
16
+ assert_file('spec/support/steps/example_steps.rb')
17
+ assert_file('spec/turnip_helper.rb')
18
+ assert_file('tasks/turnip.rake')
19
+
20
+ assert_directory('spec/features')
21
+ assert_directory('spec/support/steps')
22
+ end
23
+ end
24
+
25
+ def test_turnip_add_on_modular
26
+ run_hoboken(:generate, type: :modular, test_framework: 'rspec') do
27
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
28
+ result = execute("#{bin_path} add:turnip")
29
+ assert_match(/Gemfile updated/, result)
30
+
31
+ assert_file('Gemfile', /turnip/)
32
+ assert_file('Rakefile', /task ci: %w\[spec turnip\]/)
33
+ assert_file('Rakefile', /task default: %w\[spec turnip\]/)
34
+ assert_file('spec/features/example.feature')
35
+ assert_file('spec/support/steps/example_steps.rb')
36
+ assert_file('spec/turnip_helper.rb')
37
+ assert_file('tasks/turnip.rake')
38
+
39
+ assert_directory('spec/features')
40
+ assert_directory('spec/support/steps')
41
+ end
42
+ end
43
+
44
+ def test_turnip_without_rspec
45
+ run_hoboken(:generate, rubocop: false, run_tests: false) do
46
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
47
+ result = execute("#{bin_path} add:turnip")
48
+ assert_match(/Turnip requires RSpec/, result)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test_helper'
4
+
5
+ class TwitterBootstrapTest < IntegrationTestCase
6
+ def test_twitter_bootstrap_add_on_classic
7
+ run_hoboken(:generate) do
8
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
9
+ result = execute("#{bin_path} add:twbs")
10
+ assert_match(/Gemfile updated/, result)
11
+
12
+ assert_file('Gemfile', /bootstrap/)
13
+ assert_file('config/environment.rb', /require 'bootstrap'/)
14
+ assert_file('assets/stylesheets/styles.scss', /@import "bootstrap"/)
15
+ assert_file('assets/javascripts/app.js', /require popper/)
16
+ assert_file('assets/javascripts/app.js', /require bootstrap-sprockets/)
17
+ assert_file_does_not_have_content('views/layout.erb', /normalize/)
18
+ execute('bundle exec rake assets:precompile')
19
+ assert_directory('public/assets')
20
+ end
21
+ end
22
+
23
+ def test_twitter_bootstrap_add_on_modular
24
+ run_hoboken(:generate, type: :modular) do
25
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
26
+ result = execute("#{bin_path} add:twbs")
27
+ assert_match(/Gemfile updated/, result)
28
+
29
+ assert_file('Gemfile', /bootstrap/)
30
+ assert_file('config/environment.rb', /require 'bootstrap'/)
31
+ assert_file('assets/stylesheets/styles.scss', /@import "bootstrap"/)
32
+ assert_file('assets/javascripts/app.js', /require popper/)
33
+ assert_file('assets/javascripts/app.js', /require bootstrap-sprockets/)
34
+ assert_file_does_not_have_content('views/layout.erb', /normalize/)
35
+ execute('bundle exec rake assets:precompile')
36
+ assert_directory('public/assets')
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test_helper'
4
+
5
+ class VcrTest < IntegrationTestCase
6
+ # rubocop:disable Metrics/MethodLength
7
+ def test_vcr_add_on_test_unit
8
+ run_hoboken(:generate) do
9
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
10
+ result = execute("#{bin_path} add:vcr")
11
+ assert_match(/Gemfile updated/, result)
12
+
13
+ assert_file('Gemfile', /vcr/)
14
+ assert_file('Gemfile', /webmock/)
15
+ assert_file('test/support/vcr_setup.rb')
16
+ assert_file('test/test_helper.rb', "require_relative 'support/vcr_setup'")
17
+
18
+ assert_file(
19
+ 'test/support/vcr_setup.rb',
20
+ "c.cassette_library_dir = 'test/fixtures/vcr_cassettes'"
21
+ )
22
+
23
+ assert_file_does_not_have_content(
24
+ 'test/support/vcr_setup.rb',
25
+ 'c.configure_rspec_metadata!'
26
+ )
27
+
28
+ assert_directory('test/fixtures/vcr_cassettes')
29
+ end
30
+ end
31
+ # rubocop:enable Metrics/MethodLength
32
+
33
+ def test_vcr_add_on_rspec
34
+ run_hoboken(:generate, test_framework: 'rspec') do
35
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
36
+ result = execute("#{bin_path} add:vcr")
37
+ assert_match(/Gemfile updated/, result)
38
+
39
+ assert_file('Gemfile', /vcr/)
40
+ assert_file('Gemfile', /webmock/)
41
+ assert_file('spec/support/vcr_setup.rb')
42
+ assert_file('spec/spec_helper.rb', "require 'support/vcr_setup'")
43
+
44
+ assert_file(
45
+ 'spec/support/vcr_setup.rb',
46
+ "c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'"
47
+ )
48
+
49
+ assert_file('spec/support/vcr_setup.rb', 'c.configure_rspec_metadata!')
50
+
51
+ assert_directory('spec/fixtures/vcr_cassettes')
52
+ end
53
+ end
54
+ end
data/test/test_helper.rb CHANGED
@@ -24,16 +24,10 @@ class IntegrationTestCase < Test::Unit::TestCase
24
24
  end
25
25
  end
26
26
 
27
- # rubocop:disable Metrics/AbcSize
28
27
  def run_hoboken(command, **opts)
29
- options = [].tap do |o|
30
- o << '--git' if opts.fetch(:git, false)
31
- o << '--tiny' if opts.fetch(:tiny, false)
32
- o << '--api-only' if opts.fetch(:api_only, false)
33
- o << "--test_framework=#{opts[:test_framework]}" if opts.key?(:test_framework)
34
- o << "--type=#{opts[:type]}" if opts.key?(:type)
35
- o << "--ruby-version=#{opts[:ruby_version]}" if opts.key?(:ruby_version)
36
- end
28
+ options = extract_cli_options(opts)
29
+ check_rubocop = opts.fetch(:rubocop, true)
30
+ run_app_tests_or_specs = opts.fetch(:run_tests, true)
37
31
 
38
32
  $hoboken_counter += 1
39
33
  bin_path = File.expand_path('../bin/hoboken', __dir__)
@@ -42,8 +36,10 @@ class IntegrationTestCase < Test::Unit::TestCase
42
36
  `#{bin_path} #{command} #{DESTINATION}/#{$hoboken_counter}/sample #{options.join(' ')}`
43
37
  # rubocop:enable Layout/LineLength
44
38
  yield
39
+
40
+ assert_match(/0 failures/, execute('rake')) if run_app_tests_or_specs
41
+ assert_match(/no offenses detected/, execute('rubocop')) if check_rubocop
45
42
  end
46
- # rubocop:enable Metrics/AbcSize
47
43
 
48
44
  def execute(command)
49
45
  FileUtils.cd("#{DESTINATION}/#{$hoboken_counter}/sample") do
@@ -94,5 +90,20 @@ class IntegrationTestCase < Test::Unit::TestCase
94
90
  !File.directory?(File.join(DESTINATION, $hoboken_counter.to_s, 'sample', name))
95
91
  end
96
92
  end
93
+
94
+ private
95
+
96
+ # rubocop:disable Metrics/AbcSize
97
+ def extract_cli_options(opts)
98
+ [].tap do |o|
99
+ o << '--git' if opts.fetch(:git, false)
100
+ o << '--tiny' if opts.fetch(:tiny, false)
101
+ o << '--api-only' if opts.fetch(:api_only, false)
102
+ o << "--test_framework=#{opts[:test_framework]}" if opts.key?(:test_framework)
103
+ o << "--type=#{opts[:type]}" if opts.key?(:type)
104
+ o << "--ruby-version=#{opts[:ruby_version]}" if opts.key?(:ruby_version)
105
+ end
106
+ end
107
+ # rubocop:enable Metrics/AbcSize
97
108
  end
98
109
  # rubocop:enable Style/GlobalVars
data/www/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'middleman', '~> 4.4'
4
+ gem 'middleman-livereload', '~> 3.4'
data/www/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # Hoboken Docs
2
+ Project site for [Hoboken](https://github.com/bnadlerjr/hoboken).
data/www/config.rb ADDED
@@ -0,0 +1,11 @@
1
+ set :css_dir, 'stylesheets'
2
+ set :js_dir, 'javascripts'
3
+ set :images_dir, 'images'
4
+
5
+ configure :build do
6
+ activate :minify_css
7
+ activate :minify_javascript
8
+ activate :asset_hash
9
+ activate :relative_assets
10
+ set :relative_links, true
11
+ end