hoboken 0.0.1.beta2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +5 -5
  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/.github/dependabot.yml +7 -0
  6. data/.github/workflows/ruby.yml +28 -0
  7. data/.gitignore +3 -0
  8. data/.rubocop.yml +41 -0
  9. data/.ruby-version +1 -0
  10. data/.tool-versions +1 -0
  11. data/CHANGELOG.md +131 -0
  12. data/CODE_OF_CONDUCT.md +8 -0
  13. data/CONTRIBUTING.md +16 -0
  14. data/Gemfile +2 -0
  15. data/IDEAS.md +57 -0
  16. data/LICENSE.txt +1 -1
  17. data/README.md +28 -17
  18. data/Rakefile +14 -8
  19. data/bin/hoboken +2 -1
  20. data/hoboken.gemspec +63 -16
  21. data/lib/hoboken/actions.rb +11 -6
  22. data/lib/hoboken/add_ons/active_record.rb +142 -0
  23. data/lib/hoboken/add_ons/airbrake.rb +64 -0
  24. data/lib/hoboken/add_ons/github_action.rb +14 -0
  25. data/lib/hoboken/add_ons/heroku.rb +29 -0
  26. data/lib/hoboken/add_ons/internationalization.rb +28 -0
  27. data/lib/hoboken/add_ons/metrics.rb +60 -0
  28. data/lib/hoboken/add_ons/omniauth.rb +174 -0
  29. data/lib/hoboken/add_ons/rubocop.rb +46 -0
  30. data/lib/hoboken/add_ons/sequel.rb +135 -0
  31. data/lib/hoboken/add_ons/sidekiq.rb +137 -0
  32. data/lib/hoboken/add_ons/travis.rb +15 -0
  33. data/lib/hoboken/add_ons/turnip.rb +109 -0
  34. data/lib/hoboken/add_ons/twbs.rb +50 -0
  35. data/lib/hoboken/add_ons/vcr.rb +54 -0
  36. data/lib/hoboken/generate.rb +146 -46
  37. data/lib/hoboken/templates/Gemfile.erb.tt +43 -8
  38. data/lib/hoboken/templates/README.md.tt +117 -35
  39. data/lib/hoboken/templates/Rakefile.tt +20 -16
  40. data/lib/hoboken/templates/active_record.rake +11 -0
  41. data/lib/hoboken/templates/airbrake.rb.tt +13 -0
  42. data/lib/hoboken/templates/classic.rb.tt +25 -11
  43. data/lib/hoboken/templates/classic_environment.rb.tt +51 -0
  44. data/lib/hoboken/templates/config.ru.tt +4 -2
  45. data/lib/hoboken/templates/console +19 -0
  46. data/lib/hoboken/templates/db.rb.tt +24 -0
  47. data/lib/hoboken/templates/example_worker.rb.tt +14 -0
  48. data/lib/hoboken/templates/github_action.tt +28 -0
  49. data/lib/hoboken/templates/gitignore +8 -0
  50. data/lib/hoboken/templates/metrics.rake.tt +12 -9
  51. data/lib/hoboken/templates/modular.rb.tt +28 -15
  52. data/lib/hoboken/templates/modular_environment.rb.tt +62 -0
  53. data/lib/hoboken/templates/puma.rb.tt +21 -0
  54. data/lib/hoboken/templates/rspec.rake.tt +9 -0
  55. data/lib/hoboken/templates/rubocop.yml.tt +51 -0
  56. data/lib/hoboken/templates/seeds.rb +12 -0
  57. data/lib/hoboken/templates/sequel.rake +21 -0
  58. data/lib/hoboken/templates/server +15 -0
  59. data/lib/hoboken/templates/setup +28 -0
  60. data/lib/hoboken/templates/sidekiq.rb.tt +21 -0
  61. data/lib/hoboken/templates/spec/app_spec.rb.tt +13 -0
  62. data/lib/hoboken/templates/spec/example_worker_spec.rb.tt +16 -0
  63. data/lib/hoboken/templates/spec/rack_matchers.rb.tt +58 -0
  64. data/lib/hoboken/templates/spec/spec_helper.rb.tt +37 -0
  65. data/lib/hoboken/templates/spec/turnip_helper.rb.tt +10 -0
  66. data/lib/hoboken/templates/styles.css.tt +1 -1
  67. data/lib/hoboken/templates/support/rack_helpers.rb.tt +55 -0
  68. data/lib/hoboken/templates/support/rack_test_assertions.rb.tt +113 -0
  69. data/lib/hoboken/templates/test/test_helper.rb.tt +47 -0
  70. data/lib/hoboken/templates/test/unit/app_test.rb.tt +11 -3
  71. data/lib/hoboken/templates/test/unit/example_worker_test.rb.tt +20 -0
  72. data/lib/hoboken/templates/test_unit.rake.tt +18 -0
  73. data/lib/hoboken/templates/vcr_setup.rb.tt +15 -0
  74. data/lib/hoboken/templates/views/index.erb.tt +11 -4
  75. data/lib/hoboken/templates/views/layout.erb.tt +7 -4
  76. data/lib/hoboken/version.rb +3 -1
  77. data/lib/hoboken.rb +147 -325
  78. data/test/fixtures/Gemfile +3 -3
  79. data/test/fixtures/Gemfile.pristine +3 -2
  80. data/test/integration/active_record_test.rb +66 -0
  81. data/test/integration/airbrake_test.rb +31 -0
  82. data/test/integration/generate_classic_test.rb +75 -0
  83. data/test/integration/generate_modular_test.rb +83 -0
  84. data/test/integration/github_action_test.rb +13 -0
  85. data/test/integration/heroku_test.rb +14 -0
  86. data/test/integration/internationalization_test.rb +26 -0
  87. data/test/integration/metrics_test.rb +54 -0
  88. data/test/integration/omniauth_test.rb +143 -0
  89. data/test/integration/rubocop_test.rb +39 -0
  90. data/test/integration/sequel_test.rb +64 -0
  91. data/test/integration/sidekiq_test.rb +105 -0
  92. data/test/integration/travis_test.rb +13 -0
  93. data/test/integration/turnip_test.rb +51 -0
  94. data/test/integration/twitter_bootstrap_test.rb +39 -0
  95. data/test/integration/vcr_test.rb +54 -0
  96. data/test/test_helper.rb +109 -0
  97. data/test/unit/hoboken_actions_test.rb +82 -53
  98. data/www/Gemfile +4 -0
  99. data/www/README.md +2 -0
  100. data/www/config.rb +11 -0
  101. data/www/source/documentation.html.erb +274 -0
  102. data/www/source/images/hoboken-running.png +0 -0
  103. data/www/source/images/hoboken.png +0 -0
  104. data/www/source/images/sinatra.png +0 -0
  105. data/www/source/index.html.erb +44 -0
  106. data/www/source/javascripts/all.js +1 -0
  107. data/www/source/layouts/layout.erb +38 -0
  108. data/www/source/stylesheets/all.css.scss +116 -0
  109. data/www/source/stylesheets/normalize.css +375 -0
  110. metadata +655 -29
  111. data/lib/hoboken/templates/sprockets.rake +0 -33
  112. data/lib/hoboken/templates/sprockets_chain.rb +0 -26
  113. data/lib/hoboken/templates/sprockets_helper.rb +0 -13
  114. data/lib/hoboken/templates/test/support/rack_test_assertions.rb.tt +0 -79
  115. data/lib/hoboken/templates/test/unit/test_helper.rb.tt +0 -36
@@ -2,12 +2,15 @@
2
2
  <html>
3
3
  <head>
4
4
  <title><%= titleized_name %></title>
5
- <link rel="icon" type="image/png" href="img/favicon.png" />
5
+ <link rel="icon" type="image/png" href="<%%= image_path('images/favicon.png') %>" />
6
6
  <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/normalize/2.1.3/normalize.min.css">
7
- <link rel="stylesheet" type="text/css" href="css/styles.css">
8
- <script type="text/javascript" src="js/app.js"></script>
7
+ <%%== stylesheet_tag 'stylesheets/styles' %>
9
8
  </head>
10
9
  <body>
11
- <%%= yield %>
10
+ <% unless options[:api_only] -%>
11
+ <%%= styled_flash %>
12
+ <% end -%>
13
+ <%%== yield %>
14
+ <%%== javascript_tag 'javascripts/app' %>
12
15
  </body>
13
16
  </html>
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hoboken
2
- VERSION = "0.0.1.beta2"
4
+ VERSION = '0.10.0'
3
5
  end
data/lib/hoboken.rb CHANGED
@@ -1,352 +1,174 @@
1
- require "thor"
2
- require "thor/util"
3
- require "fileutils"
4
- require_relative "hoboken/version"
5
- require_relative "hoboken/generate"
6
- require_relative "hoboken/actions"
7
-
1
+ # frozen_string_literal: true
2
+
3
+ require 'date'
4
+ require 'thor'
5
+ require 'thor/util'
6
+ require 'fileutils'
7
+ require_relative 'hoboken/version'
8
+ require_relative 'hoboken/generate'
9
+ require_relative 'hoboken/actions'
10
+
11
+ # Generate Sinatra project templates.
12
+ #
8
13
  module Hoboken
9
- class OmniAuth < Thor::Group
14
+ # Custom `Thor::Group` that mixes in `Hoboken::Actions` so that they're
15
+ # available everywhere.
16
+ #
17
+ class Group < Thor::Group
10
18
  include Thor::Actions
11
19
  include Hoboken::Actions
12
20
 
13
- attr_reader :provider
14
-
15
21
  def self.source_root
16
22
  File.dirname(__FILE__)
17
23
  end
18
24
 
19
- def add_gem
20
- @provider = ask("Specify a provider (i.e. twitter, facebook. etc.): ").downcase
21
- provider_version = ask("Specify provider version: ")
22
- gem gem_name, provider_version
23
- end
24
-
25
- def setup_middleware
26
- insert_into_file("app.rb", after: /require "sinatra("|\/base")/) do
27
- "\nrequire \"#{gem_name}\""
28
- end
29
-
30
- snippet = <<-CODE
31
-
32
- use OmniAuth::Builder do
33
- provider :#{provider}, ENV["#{provider.upcase}_KEY"], ENV["#{provider.upcase}_SECRET"]
34
- end
35
-
36
- CODE
37
-
38
- text = modular? ? indent(snippet, 4) : snippet
39
- insert_into_file("app.rb", after: /use Rack::Session::Cookie.+\n/) { text }
40
- end
41
-
42
- def add_routes
43
- routes = <<-CODE
44
-
45
-
46
- get "/login" do
47
- '<a href="/auth/#{provider}">Login</a>'
48
- end
49
-
50
- get "/auth/:provider/callback" do
51
- # TODO: Insert real authentication logic...
52
- MultiJson.encode(request.env['omniauth.auth'])
53
- end
54
-
55
- get "/auth/failure" do
56
- # TODO: Insert real error handling logic...
57
- halt 401, params[:message]
58
- end
59
- CODE
60
-
61
- if modular?
62
- insert_into_file("app.rb", after: /get.+?end$/m) { indent(routes, 4) }
63
- else
64
- append_file("app.rb", routes)
65
- end
66
- end
67
-
68
- def add_tests
69
- inject_into_class("test/unit/app_test.rb", "AppTest") do
70
- <<-CODE
71
- setup do
72
- OmniAuth.config.test_mode = true
73
- end
74
-
75
- test "GET /login" do
76
- get "/login"
77
- assert_equal('<a href="/auth/#{provider}">Login</a>', last_response.body)
78
- end
79
-
80
- test "GET /auth/#{provider}/callback" do
81
- auth_hash = {
82
- "provider" => "#{provider}",
83
- "uid" => "123545",
84
- "info" => {
85
- "name" => "John Doe"
86
- }
87
- }
88
-
89
- OmniAuth.config.mock_auth[:#{provider}] = auth_hash
90
- get "/auth/fitbit/callback"
91
- assert_equal(MultiJson.encode(auth_hash), last_response.body)
92
- end
93
-
94
- test "GET /auth/failure" do
95
- OmniAuth.config.mock_auth[:#{provider}] = :invalid_credentials
96
- get "/auth/failure"
97
- assert_response :not_authorized
98
- end
99
-
100
- CODE
101
- end
102
- end
103
-
104
- def reminders
105
- say "\nGemfile updated... don't forget to 'bundle install'"
106
- end
107
-
108
- private
109
-
110
- def gem_name
111
- "omniauth-#{provider}"
25
+ def classic?
26
+ File.read('app.rb').include?("require 'sinatra'")
112
27
  end
113
28
 
114
29
  def modular?
115
- @modular ||= File.readlines("app.rb").grep(/Sinatra::Base/).any?
116
- end
117
- end
118
-
119
- class Sprockets < Thor::Group
120
- include Thor::Actions
121
- include Hoboken::Actions
122
-
123
- def self.source_root
124
- File.dirname(__FILE__)
125
- end
126
-
127
- def create_assets_folder
128
- empty_directory("assets")
129
- FileUtils.cp("public/css/styles.css", "assets/styles.css")
130
- FileUtils.cp("public/js/app.js", "assets/app.js")
131
- end
132
-
133
- def add_gems
134
- gem "sprockets", "2.10.0", group: :assets
135
- gem "uglifier", "2.1.1", group: :assets
136
- gem "yui-compressor", "0.9.6", group: :assets
137
- end
138
-
139
- def copy_sprockets_helpers
140
- copy_file("hoboken/templates/sprockets.rake", "tasks/sprockets.rake")
141
- copy_file("hoboken/templates/sprockets_chain.rb", "middleware/sprockets_chain.rb")
142
- copy_file("hoboken/templates/sprockets_helper.rb", "helpers/sprockets.rb")
143
- end
144
-
145
- def update_app
146
- insert_into_file("app.rb", after: /configure :development do\n/) do
147
- <<CODE
148
- require File.expand_path('middleware/sprockets_chain', settings.root)
149
- use Middleware::SprocketsChain, %r{/assets} do |env|
150
- %w(assets vendor).each do |f|
151
- env.append_path File.expand_path("../\#{f}", __FILE__)
152
- end
153
- end
154
-
155
- CODE
156
- end
157
-
158
- insert_into_file("app.rb", after: /set :root, File.dirname\(__FILE__\)\n/) do
159
- " helpers Helpers::Sprockets"
160
- end
161
-
162
- gsub_file("app.rb", /require "sinatra\/reloader" if development\?/) do
163
- <<CODE
164
- if development?
165
- require "sinatra/reloader"
166
-
167
- require File.expand_path('middleware/sprockets_chain', settings.root)
168
- use Middleware::SprocketsChain, %r{/assets} do |env|
169
- %w(assets vendor).each do |f|
170
- env.append_path File.expand_path("../\#{f}", __FILE__)
171
- end
172
- end
173
- end
174
-
175
- helpers Helpers::Sprockets
176
- CODE
177
- end
178
- end
179
-
180
- def adjust_link_tags
181
- insert_into_file("views/layout.erb", before: /<\/head>/) do
182
- <<HTML
183
- <%= stylesheet_tag :styles %>
184
-
185
- <%= javascript_tag :app %>
186
- HTML
187
- end
188
-
189
- gsub_file("views/layout.erb", /<link rel="stylesheet" type="text\/css" href="css\/styles.css">/, "")
190
- gsub_file("views/layout.erb", /<script type="text\/javascript" src="js\/app.js"><\/script>/, "")
191
- end
192
-
193
- def directions
194
- text = <<TEXT
195
-
196
- Run `bundle install` to get the sprockets gem and its
197
- dependencies.
198
-
199
- Running the server in development mode will serve css
200
- and js files from /assets. In order to serve assets in
201
- production, you must run `rake assets:precompile`. Read
202
- the important note below before running this rake task.
203
- TEXT
204
-
205
- important = <<TEXT
206
-
207
- Important Note:
208
- Any css or js files from the /public folder have been copied
209
- to /assets, the original files remain intact in /public, but
210
- will be replaced the first time you run `rake assets:precompile`.
211
- You may want to backup those files if they are not under source
212
- control before running the Rake command.
213
- TEXT
214
-
215
- say text
216
- say important, :red
30
+ !classic?
217
31
  end
218
- end
219
-
220
- class Heroku < Thor::Group
221
- include Thor::Actions
222
- include Hoboken::Actions
223
32
 
224
- def self.source_root
225
- File.dirname(__FILE__)
33
+ def rspec?
34
+ Dir.exist?('spec')
226
35
  end
227
36
 
228
- def add_gem
229
- gem "foreman", "0.63.0", group: :development
37
+ def rubocop?
38
+ File.exist?('.rubocop.yml')
230
39
  end
231
40
 
232
- def procfile
233
- create_file("Procfile") do
234
- "web: bundle exec thin start -p $PORT -e $RACK_ENV"
235
- end
236
- end
237
-
238
- def env_file
239
- create_file(".env") do
240
- "RACK_ENV=development\nPORT=9292"
241
- end
242
- append_to_file(".gitignore", ".env") if File.exist?(".gitignore")
243
- end
244
-
245
- def slugignore
246
- create_file(".slugignore") do
247
- "tags\n/test\n/tmp"
248
- end
249
- end
250
-
251
- def fix_stdout_for_logging
252
- prepend_file("config.ru", "$stdout.sync = true\n")
253
- end
254
-
255
- def replace_server_rake_task
256
- gsub_file("Rakefile", /desc.*server.*{rack_env}"\)\nend$/m) do
257
- <<TASK
258
- desc "Start the development server with Foreman"
259
- task :server do
260
- exec("foreman start")
261
- end
262
- TASK
263
- end
264
- end
265
-
266
- def reminders
267
- say "\nGemfile updated... don't forget to 'bundle install'"
268
- end
269
- end
270
-
271
- class Internationalization < Thor::Group
272
- include Thor::Actions
273
- include Hoboken::Actions
274
-
275
- def self.source_root
276
- File.dirname(__FILE__)
277
- end
278
-
279
- def add_gem
280
- gem "sinatra-r18n", "1.1.5"
281
- insert_into_file("app.rb", after: /require "sinatra("|\/base")/) do
282
- "\nrequire \"sinatra/r18n\""
283
- end
284
- insert_into_file("app.rb", after: /Sinatra::Base/) do
285
- "\n register Sinatra::R18n"
286
- end
287
- end
288
-
289
- def translations
290
- empty_directory("i18n")
291
- template("hoboken/templates/en.yml.tt", "i18n/en.yml")
292
- end
293
-
294
- def reminders
295
- say "\nGemfile updated... don't forget to 'bundle install'"
296
- end
297
- end
298
-
299
- class Metrics < Thor::Group
300
- include Thor::Actions
301
- include Hoboken::Actions
302
-
303
- def self.source_root
304
- File.dirname(__FILE__)
305
- end
306
-
307
- def add_gems
308
- gem "flog", "2.5.3", group: :test
309
- gem "flay", "1.4.3", group: :test
310
- gem "simplecov", "0.7.1", require: false, group: :test
311
- end
312
-
313
- def copy_task_templates
314
- empty_directory("tasks")
315
- template("hoboken/templates/metrics.rake.tt", "tasks/metrics.rake")
316
- end
317
-
318
- def simplecov_snippet
319
- insert_into_file "test/unit/test_helper.rb", before: /require "test\/unit"/ do
320
- <<CODE
321
-
322
- require 'simplecov'
323
- SimpleCov.start do
324
- add_filter "/test/"
325
- coverage_dir 'tmp/coverage'
326
- end
327
-
328
- CODE
329
- end
330
- end
331
-
332
- def reminders
333
- say "\nGemfile updated... don't forget to 'bundle install'"
41
+ def sequel?
42
+ File.exist?('tasks/sequel.rake')
334
43
  end
335
44
  end
336
45
 
46
+ require_relative 'hoboken/add_ons/active_record'
47
+ require_relative 'hoboken/add_ons/airbrake'
48
+ require_relative 'hoboken/add_ons/github_action'
49
+ require_relative 'hoboken/add_ons/heroku'
50
+ require_relative 'hoboken/add_ons/internationalization'
51
+ require_relative 'hoboken/add_ons/metrics'
52
+ require_relative 'hoboken/add_ons/omniauth'
53
+ require_relative 'hoboken/add_ons/rubocop'
54
+ require_relative 'hoboken/add_ons/sequel'
55
+ require_relative 'hoboken/add_ons/sidekiq'
56
+ require_relative 'hoboken/add_ons/travis'
57
+ require_relative 'hoboken/add_ons/turnip'
58
+ require_relative 'hoboken/add_ons/twbs'
59
+ require_relative 'hoboken/add_ons/vcr'
60
+
61
+ # Hoboken's command-line interface.
62
+ #
337
63
  class CLI < Thor
338
- desc "version", "Print version and quit"
64
+ desc 'version', 'Print version and quit'
339
65
  def version
340
66
  puts "Hoboken v#{Hoboken::VERSION}"
341
67
  end
342
68
 
343
- register(Generate, "generate", "generate [APP_NAME]", "Generate a new Sinatra app")
344
- tasks["generate"].options = Hoboken::Generate.class_options
345
-
346
- register(Metrics, "add:metrics", "add:metrics", "Add metrics (flog, flay, simplecov)")
347
- register(Internationalization, "add:i18n", "add:i18n", "Internationalization support using sinatra-r18n")
348
- register(Heroku, "add:heroku", "add:heroku", "Heroku deployment support")
349
- register(OmniAuth, "add:omniauth", "add:omniauth", "OmniAuth authentication (allows you to select a provider)")
350
- register(Sprockets, "add:sprockets", "add:sprockets", "Rack-based asset packaging system")
69
+ register(Generate, 'generate', 'generate [APP_NAME]', 'Generate a new Sinatra app')
70
+ tasks['generate'].options = Hoboken::Generate.class_options
71
+
72
+ register(
73
+ AddOns::ActiveRecord,
74
+ 'add:active_record',
75
+ 'add:active_record',
76
+ 'ActiveRecord database access via sinatra-activerecord gem'
77
+ )
78
+
79
+ register(
80
+ AddOns::Airbrake,
81
+ 'add:airbrake',
82
+ 'add:airbrake',
83
+ 'Support for official Airbrake library for Ruby applications'
84
+ )
85
+
86
+ register(
87
+ AddOns::GithubAction,
88
+ 'add:github_action',
89
+ 'add:github_action',
90
+ 'Github action that runs CI task'
91
+ )
92
+
93
+ register(
94
+ AddOns::Heroku,
95
+ 'add:heroku',
96
+ 'add:heroku',
97
+ 'Heroku deployment support'
98
+ )
99
+
100
+ register(
101
+ AddOns::Internationalization,
102
+ 'add:i18n',
103
+ 'add:i18n',
104
+ 'Internationalization support using sinatra-r18n'
105
+ )
106
+
107
+ register(
108
+ AddOns::Metrics,
109
+ 'add:metrics',
110
+ 'add:metrics',
111
+ 'Add metrics (flog, flay, simplecov)'
112
+ )
113
+
114
+ register(
115
+ AddOns::OmniAuth,
116
+ 'add:omniauth',
117
+ 'add:omniauth',
118
+ 'OmniAuth authentication (allows you to select a provider)'
119
+ )
120
+
121
+ register(
122
+ AddOns::Rubocop,
123
+ 'add:rubocop',
124
+ 'add:rubocop',
125
+ 'Basic Rubocop configuration and Rake task.'
126
+ )
127
+
128
+ register(
129
+ AddOns::Sequel,
130
+ 'add:sequel',
131
+ 'add:sequel',
132
+ 'Database access via Sequel gem'
133
+ )
134
+
135
+ register(
136
+ AddOns::Sidekiq,
137
+ 'add:sidekiq',
138
+ 'add:sidekiq',
139
+ 'Background processing with the Sidekiq gem'
140
+ )
141
+
142
+ register(
143
+ AddOns::Travis,
144
+ 'add:travis',
145
+ 'add:travis',
146
+ 'Basic Travis-CI YAML config'
147
+ )
148
+
149
+ register(
150
+ AddOns::Turnip,
151
+ 'add:turnip',
152
+ 'add:turnip',
153
+ 'Gherkin extension for RSpec'
154
+ )
155
+
156
+ register(
157
+ AddOns::TwitterBootstrap,
158
+ 'add:twbs',
159
+ 'add:twbs',
160
+ 'Twitter Bootstrap'
161
+ )
162
+
163
+ register(
164
+ AddOns::Vcr,
165
+ 'add:vcr',
166
+ 'add:vcr',
167
+ 'Record HTTP interactions and replay them during test runs'
168
+ )
169
+
170
+ def self.exit_on_failure?
171
+ true
172
+ end
351
173
  end
352
174
  end
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
2
- ruby "2.0.0"
1
+ source 'https://rubygems.org'
2
+ ruby '2.0.0'
3
3
 
4
- gem "sinatra", "~> 1.4.4", require: false, group: [:test, :development]
4
+ gem 'sinatra'
@@ -1,2 +1,3 @@
1
- source "https://rubygems.org"
2
- ruby "2.0.0"
1
+ source 'https://rubygems.org'
2
+ ruby '2.0.0'
3
+
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test_helper'
4
+
5
+ class ActiveRecord < IntegrationTestCase
6
+ # rubocop:disable Metrics/MethodLength
7
+ def test_activerecord_add_on
8
+ run_hoboken(:generate) do
9
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
10
+ execute("#{bin_path} add:active_record")
11
+ execute('echo "DATABASE_URL=sqlite3:db/development.db" > .env')
12
+
13
+ assert_file('Gemfile', 'sinatra-activerecord', 'sqlite3')
14
+ assert_file('db/seeds.rb')
15
+ assert_file('tasks/active_record.rake')
16
+
17
+ assert_file('config/environment.rb', "require 'sinatra/activerecord'")
18
+ assert_file('config/puma.rb', 'ActiveRecord::Base.establish_connection')
19
+
20
+ assert_file(
21
+ 'test/test_helper.rb',
22
+ %r{ENV\['DATABASE_URL'\] = 'sqlite3:db/test\.db'}
23
+ )
24
+
25
+ assert_file('test/test_helper.rb', <<-CODE
26
+ def run(*args, &block)
27
+ result = nil
28
+ ActiveRecord::Base.connection.transaction do
29
+ result = super
30
+ raise ActiveRecord::Rollback
31
+ end
32
+ result
33
+ end
34
+ CODE
35
+ )
36
+ end
37
+ end
38
+ # rubocop:enable Metrics/MethodLength
39
+
40
+ # rubocop:disable Metrics/MethodLength
41
+ def test_activerecord_add_on_with_rspec
42
+ run_hoboken(:generate, test_framework: 'rspec') do
43
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
44
+ execute("#{bin_path} add:active_record")
45
+ execute("#{bin_path} add:rubocop")
46
+ execute('echo "DATABASE_URL=sqlite3:db/development.db" > .env')
47
+
48
+ assert_file(
49
+ 'spec/spec_helper.rb',
50
+ %r{ENV\['DATABASE_URL'\] = 'sqlite3:db/test\.db'}
51
+ )
52
+
53
+ assert_file('spec/spec_helper.rb', <<-CODE
54
+ config.around do |example|
55
+ ActiveRecord::Base.transaction do
56
+ example.run
57
+ ActiveRecord::Rollback
58
+ end
59
+ end
60
+
61
+ CODE
62
+ )
63
+ end
64
+ end
65
+ # rubocop:enable Metrics/MethodLength
66
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test_helper'
4
+
5
+ class AirbrakeTest < IntegrationTestCase
6
+ def test_airbrake_add_on_with_classic
7
+ run_hoboken(:generate) do
8
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
9
+ execute("#{bin_path} add:airbrake")
10
+ assert_file('Gemfile', 'airbrake')
11
+ assert_file('README.md', 'AIRBRAKE_PROJECT_ID')
12
+ assert_file('README.md', 'AIRBRAKE_PROJECT_KEY')
13
+ assert_file('config/airbrake.rb')
14
+ assert_file('config/environment.rb', "require_relative 'airbrake'")
15
+ assert_file('config/environment.rb', 'use Airbrake::Rack::Middleware')
16
+ end
17
+ end
18
+
19
+ def test_airbrake_add_on_with_modular
20
+ run_hoboken(:generate, type: :modular) do
21
+ bin_path = File.expand_path('../../bin/hoboken', __dir__)
22
+ execute("#{bin_path} add:airbrake")
23
+ assert_file('Gemfile', 'airbrake')
24
+ assert_file('README.md', 'AIRBRAKE_PROJECT_ID')
25
+ assert_file('README.md', 'AIRBRAKE_PROJECT_KEY')
26
+ assert_file('config/airbrake.rb')
27
+ assert_file('config/environment.rb', "require_relative 'airbrake'")
28
+ assert_file('config/environment.rb', 'use Airbrake::Rack::Middleware')
29
+ end
30
+ end
31
+ end