hoboken 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +33 -0
- data/.github/ISSUE_TEMPLATE/code_change.md +11 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +25 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +13 -5
- data/.tool-versions +1 -0
- data/CHANGELOG.md +131 -0
- data/CODE_OF_CONDUCT.md +8 -0
- data/CONTRIBUTING.md +16 -0
- data/README.md +10 -14
- data/Rakefile +7 -16
- data/hoboken.gemspec +18 -8
- data/lib/hoboken/add_ons/active_record.rb +142 -0
- data/lib/hoboken/add_ons/airbrake.rb +64 -0
- data/lib/hoboken/add_ons/heroku.rb +5 -1
- data/lib/hoboken/add_ons/internationalization.rb +2 -2
- data/lib/hoboken/add_ons/metrics.rb +3 -2
- data/lib/hoboken/add_ons/omniauth.rb +9 -8
- data/lib/hoboken/add_ons/rubocop.rb +10 -4
- data/lib/hoboken/add_ons/sequel.rb +55 -29
- data/lib/hoboken/add_ons/sidekiq.rb +137 -0
- data/lib/hoboken/add_ons/turnip.rb +109 -0
- data/lib/hoboken/add_ons/twbs.rb +5 -35
- data/lib/hoboken/add_ons/vcr.rb +54 -0
- data/lib/hoboken/generate.rb +18 -10
- data/lib/hoboken/templates/Gemfile.erb.tt +13 -3
- data/lib/hoboken/templates/README.md.tt +18 -6
- data/lib/hoboken/templates/Rakefile.tt +11 -0
- data/lib/hoboken/templates/active_record.rake +11 -0
- data/lib/hoboken/templates/airbrake.rb.tt +13 -0
- data/lib/hoboken/templates/classic.rb.tt +6 -20
- data/lib/hoboken/templates/classic_environment.rb.tt +51 -0
- data/lib/hoboken/templates/config.ru.tt +2 -4
- data/lib/hoboken/templates/console +19 -0
- data/lib/hoboken/templates/example_worker.rb.tt +14 -0
- data/lib/hoboken/templates/metrics.rake.tt +3 -1
- data/lib/hoboken/templates/modular.rb.tt +8 -25
- data/lib/hoboken/templates/modular_environment.rb.tt +62 -0
- data/lib/hoboken/templates/rspec.rake.tt +7 -3
- data/lib/hoboken/templates/rubocop.yml.tt +23 -3
- data/lib/hoboken/templates/seeds.rb +12 -0
- data/lib/hoboken/templates/server +15 -0
- data/lib/hoboken/templates/setup +28 -0
- data/lib/hoboken/templates/sidekiq.rb.tt +21 -0
- data/lib/hoboken/templates/spec/app_spec.rb.tt +0 -2
- data/lib/hoboken/templates/spec/example_worker_spec.rb.tt +16 -0
- data/lib/hoboken/templates/spec/rack_matchers.rb.tt +8 -6
- data/lib/hoboken/templates/spec/spec_helper.rb.tt +2 -6
- data/lib/hoboken/templates/spec/turnip_helper.rb.tt +10 -0
- data/lib/hoboken/templates/styles.css.tt +1 -1
- data/lib/hoboken/templates/support/rack_test_assertions.rb.tt +5 -3
- data/lib/hoboken/templates/test/test_helper.rb.tt +2 -5
- data/lib/hoboken/templates/test/unit/example_worker_test.rb.tt +20 -0
- data/lib/hoboken/templates/vcr_setup.rb.tt +15 -0
- data/lib/hoboken/templates/views/index.erb.tt +1 -1
- data/lib/hoboken/templates/views/layout.erb.tt +3 -3
- data/lib/hoboken/version.rb +1 -1
- data/lib/hoboken.rb +54 -10
- data/test/integration/active_record_test.rb +66 -0
- data/test/integration/airbrake_test.rb +31 -0
- data/test/integration/generate_classic_test.rb +75 -0
- data/test/integration/generate_modular_test.rb +83 -0
- data/test/integration/github_action_test.rb +13 -0
- data/test/integration/heroku_test.rb +14 -0
- data/test/integration/internationalization_test.rb +26 -0
- data/test/integration/metrics_test.rb +54 -0
- data/test/integration/omniauth_test.rb +143 -0
- data/test/integration/rubocop_test.rb +39 -0
- data/test/integration/sequel_test.rb +64 -0
- data/test/integration/sidekiq_test.rb +105 -0
- data/test/integration/travis_test.rb +13 -0
- data/test/integration/turnip_test.rb +51 -0
- data/test/integration/twitter_bootstrap_test.rb +39 -0
- data/test/integration/vcr_test.rb +54 -0
- data/test/test_helper.rb +21 -10
- data/www/Gemfile +4 -0
- data/www/README.md +2 -0
- data/www/config.rb +11 -0
- data/www/source/documentation.html.erb +274 -0
- data/www/source/images/hoboken-running.png +0 -0
- data/www/source/images/hoboken.png +0 -0
- data/www/source/images/sinatra.png +0 -0
- data/www/source/index.html.erb +44 -0
- data/www/source/javascripts/all.js +1 -0
- data/www/source/layouts/layout.erb +38 -0
- data/www/source/stylesheets/all.css.scss +116 -0
- data/www/source/stylesheets/normalize.css +375 -0
- metadata +230 -44
- data/lib/hoboken/add_ons/sprockets.rb +0 -99
- data/lib/hoboken/templates/console.sh +0 -5
- data/lib/hoboken/templates/server.sh +0 -12
- data/lib/hoboken/templates/setup.sh +0 -7
- data/lib/hoboken/templates/sprockets.rake +0 -39
- data/lib/hoboken/templates/sprockets_chain.rb +0 -30
- data/lib/hoboken/templates/sprockets_helper.rb +0 -17
- data/test/integration/add_on_test.rb +0 -505
- data/test/integration/generate_test.rb +0 -203
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Refer to the Sidekiq documentation[1] for more information about testing
|
4
|
+
# workers.
|
5
|
+
#
|
6
|
+
# [1]: https://github.com/mperham/sidekiq/wiki/Testing
|
7
|
+
#
|
8
|
+
RSpec.describe ExampleWorker, sidekiq: true do
|
9
|
+
subject(:worker) { described_class }
|
10
|
+
|
11
|
+
it 'performs work' do
|
12
|
+
expect {
|
13
|
+
worker.perform_async
|
14
|
+
}.to change(worker.jobs, :size).by(1)
|
15
|
+
end
|
16
|
+
end
|
@@ -7,16 +7,18 @@ RSpec::Matchers.define :have_http_status do |expected|
|
|
7
7
|
|
8
8
|
failure_message do |response|
|
9
9
|
'expected last response status to be ' \
|
10
|
-
|
11
|
-
|
10
|
+
"#{response_codes.fetch(expected, 'unknown')}, " \
|
11
|
+
"but was #{response.status}"
|
12
12
|
end
|
13
13
|
|
14
14
|
def response_codes
|
15
15
|
{
|
16
16
|
ok: 200,
|
17
|
+
no_content: 204,
|
17
18
|
not_authorized: 401,
|
18
19
|
not_found: 404,
|
19
|
-
redirect: 302
|
20
|
+
redirect: 302,
|
21
|
+
server_error: 500
|
20
22
|
}.freeze
|
21
23
|
end
|
22
24
|
end
|
@@ -28,8 +30,8 @@ RSpec::Matchers.define :have_content_type do |expected|
|
|
28
30
|
|
29
31
|
failure_message do |response|
|
30
32
|
'expected last response to have content type ' \
|
31
|
-
|
32
|
-
|
33
|
+
"'#{content_types.fetch(expected, 'unknown')}', " \
|
34
|
+
"but was '#{response.content_type}'"
|
33
35
|
end
|
34
36
|
|
35
37
|
def content_types
|
@@ -47,7 +49,7 @@ RSpec::Matchers.define :redirect_to do |expected|
|
|
47
49
|
|
48
50
|
failure_message do |response|
|
49
51
|
"expected last response to redirect to '#{expected}', " \
|
50
|
-
|
52
|
+
"but it redirected to '#{path(response)}'"
|
51
53
|
end
|
52
54
|
|
53
55
|
def path(response)
|
@@ -2,21 +2,17 @@
|
|
2
2
|
|
3
3
|
ENV['RACK_ENV'] = 'test'
|
4
4
|
|
5
|
-
|
5
|
+
require_relative '../config/environment'
|
6
6
|
|
7
7
|
require 'warning'
|
8
8
|
|
9
9
|
# Ignore all warnings in Gem dependencies
|
10
10
|
Gem.path.each { |path| Warning.ignore(//, path) }
|
11
11
|
|
12
|
-
require '
|
12
|
+
require 'pry-byebug'
|
13
13
|
require 'rack/test'
|
14
14
|
require 'support/rack_helpers'
|
15
15
|
|
16
|
-
require_relative '../app'
|
17
|
-
|
18
|
-
Dotenv.load
|
19
|
-
|
20
16
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
21
17
|
RSpec.configure do |config|
|
22
18
|
config.include RackHelpers, rack: true
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'spec_helper'
|
4
|
+
|
5
|
+
Dir.glob('spec/support/steps/**/*_steps.rb') { |f| load f, true }
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.raise_error_for_unimplemented_steps = true
|
9
|
+
config.include RackHelpers, feature: true
|
10
|
+
end
|
@@ -5,9 +5,11 @@ module Rack
|
|
5
5
|
module Assertions
|
6
6
|
RESPONSE_CODES = {
|
7
7
|
ok: 200,
|
8
|
+
no_content: 204,
|
8
9
|
not_authorized: 401,
|
9
10
|
not_found: 404,
|
10
|
-
redirect: 302
|
11
|
+
redirect: 302,
|
12
|
+
server_error: 500
|
11
13
|
}.freeze
|
12
14
|
|
13
15
|
CONTENT_TYPES = {
|
@@ -26,7 +28,7 @@ module Rack
|
|
26
28
|
end
|
27
29
|
|
28
30
|
def assert_content_type(content_type)
|
29
|
-
unless CONTENT_TYPES.
|
31
|
+
unless CONTENT_TYPES.key?(content_type)
|
30
32
|
raise ArgumentError, "unrecognized content_type (#{content_type})"
|
31
33
|
end
|
32
34
|
|
@@ -65,7 +67,7 @@ module Rack
|
|
65
67
|
def assert_session_has_key(key, message=nil)
|
66
68
|
assert_has_session
|
67
69
|
msg = build_message(message, 'expected session to have key named <?>', key)
|
68
|
-
assert_block(msg) { last_request.env['rack.session'].
|
70
|
+
assert_block(msg) { last_request.env['rack.session'].key?(key.to_s) }
|
69
71
|
end
|
70
72
|
|
71
73
|
def assert_session(key, expected, message=nil)
|
@@ -2,22 +2,19 @@
|
|
2
2
|
|
3
3
|
ENV['RACK_ENV'] = 'test'
|
4
4
|
|
5
|
-
|
5
|
+
require_relative '../config/environment'
|
6
6
|
|
7
7
|
require 'warning'
|
8
8
|
|
9
9
|
# Ignore all warnings in Gem dependencies
|
10
10
|
Gem.path.each { |path| Warning.ignore(//, path) }
|
11
11
|
|
12
|
-
require 'dotenv'
|
13
12
|
require 'test/unit'
|
14
13
|
require 'contest'
|
14
|
+
require 'pry-byebug'
|
15
15
|
require 'rack/test'
|
16
16
|
|
17
17
|
require_relative 'support/rack_helpers'
|
18
|
-
require_relative '../app'
|
19
|
-
|
20
|
-
Dotenv.load
|
21
18
|
|
22
19
|
module Test
|
23
20
|
module Unit
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../test_helper'
|
4
|
+
|
5
|
+
# Refer to the Sidekiq documentation[1] for more information about testing
|
6
|
+
# workers.
|
7
|
+
#
|
8
|
+
# [1]: https://github.com/mperham/sidekiq/wiki/Testing
|
9
|
+
#
|
10
|
+
class ExampleWorkerTest < Test::Unit::TestCase
|
11
|
+
setup do
|
12
|
+
Sidekiq::Worker.clear_all
|
13
|
+
end
|
14
|
+
|
15
|
+
test 'performs work' do
|
16
|
+
assert_equal 0, ExampleWorker.jobs.size
|
17
|
+
ExampleWorker.perform_async
|
18
|
+
assert_equal 1, ExampleWorker.jobs.size
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'vcr'
|
4
|
+
|
5
|
+
VCR.configure do |c|
|
6
|
+
<% if rspec? -%>
|
7
|
+
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
8
|
+
<% else -%>
|
9
|
+
c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
|
10
|
+
<% end -%>
|
11
|
+
c.hook_into :webmock
|
12
|
+
<% if rspec? -%>
|
13
|
+
c.configure_rspec_metadata!
|
14
|
+
<% end -%>
|
15
|
+
end
|
@@ -2,15 +2,15 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title><%= titleized_name %></title>
|
5
|
-
<link rel="icon" type="image/png" href="
|
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
|
-
|
8
|
-
<script type="text/javascript" src="js/app.js"></script>
|
7
|
+
<%%== stylesheet_tag 'stylesheets/styles' %>
|
9
8
|
</head>
|
10
9
|
<body>
|
11
10
|
<% unless options[:api_only] -%>
|
12
11
|
<%%= styled_flash %>
|
13
12
|
<% end -%>
|
14
13
|
<%%== yield %>
|
14
|
+
<%%== javascript_tag 'javascripts/app' %>
|
15
15
|
</body>
|
16
16
|
</html>
|
data/lib/hoboken/version.rb
CHANGED
data/lib/hoboken.rb
CHANGED
@@ -26,11 +26,25 @@ module Hoboken
|
|
26
26
|
File.read('app.rb').include?("require 'sinatra'")
|
27
27
|
end
|
28
28
|
|
29
|
+
def modular?
|
30
|
+
!classic?
|
31
|
+
end
|
32
|
+
|
29
33
|
def rspec?
|
30
34
|
Dir.exist?('spec')
|
31
35
|
end
|
36
|
+
|
37
|
+
def rubocop?
|
38
|
+
File.exist?('.rubocop.yml')
|
39
|
+
end
|
40
|
+
|
41
|
+
def sequel?
|
42
|
+
File.exist?('tasks/sequel.rake')
|
43
|
+
end
|
32
44
|
end
|
33
45
|
|
46
|
+
require_relative 'hoboken/add_ons/active_record'
|
47
|
+
require_relative 'hoboken/add_ons/airbrake'
|
34
48
|
require_relative 'hoboken/add_ons/github_action'
|
35
49
|
require_relative 'hoboken/add_ons/heroku'
|
36
50
|
require_relative 'hoboken/add_ons/internationalization'
|
@@ -38,9 +52,11 @@ module Hoboken
|
|
38
52
|
require_relative 'hoboken/add_ons/omniauth'
|
39
53
|
require_relative 'hoboken/add_ons/rubocop'
|
40
54
|
require_relative 'hoboken/add_ons/sequel'
|
41
|
-
require_relative 'hoboken/add_ons/
|
55
|
+
require_relative 'hoboken/add_ons/sidekiq'
|
42
56
|
require_relative 'hoboken/add_ons/travis'
|
57
|
+
require_relative 'hoboken/add_ons/turnip'
|
43
58
|
require_relative 'hoboken/add_ons/twbs'
|
59
|
+
require_relative 'hoboken/add_ons/vcr'
|
44
60
|
|
45
61
|
# Hoboken's command-line interface.
|
46
62
|
#
|
@@ -54,10 +70,17 @@ module Hoboken
|
|
54
70
|
tasks['generate'].options = Hoboken::Generate.class_options
|
55
71
|
|
56
72
|
register(
|
57
|
-
AddOns::
|
58
|
-
'add:
|
59
|
-
'add:
|
60
|
-
'
|
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'
|
61
84
|
)
|
62
85
|
|
63
86
|
register(
|
@@ -67,6 +90,13 @@ module Hoboken
|
|
67
90
|
'Github action that runs CI task'
|
68
91
|
)
|
69
92
|
|
93
|
+
register(
|
94
|
+
AddOns::Heroku,
|
95
|
+
'add:heroku',
|
96
|
+
'add:heroku',
|
97
|
+
'Heroku deployment support'
|
98
|
+
)
|
99
|
+
|
70
100
|
register(
|
71
101
|
AddOns::Internationalization,
|
72
102
|
'add:i18n',
|
@@ -103,10 +133,10 @@ module Hoboken
|
|
103
133
|
)
|
104
134
|
|
105
135
|
register(
|
106
|
-
AddOns::
|
107
|
-
'add:
|
108
|
-
'add:
|
109
|
-
'
|
136
|
+
AddOns::Sidekiq,
|
137
|
+
'add:sidekiq',
|
138
|
+
'add:sidekiq',
|
139
|
+
'Background processing with the Sidekiq gem'
|
110
140
|
)
|
111
141
|
|
112
142
|
register(
|
@@ -116,11 +146,25 @@ module Hoboken
|
|
116
146
|
'Basic Travis-CI YAML config'
|
117
147
|
)
|
118
148
|
|
149
|
+
register(
|
150
|
+
AddOns::Turnip,
|
151
|
+
'add:turnip',
|
152
|
+
'add:turnip',
|
153
|
+
'Gherkin extension for RSpec'
|
154
|
+
)
|
155
|
+
|
119
156
|
register(
|
120
157
|
AddOns::TwitterBootstrap,
|
121
158
|
'add:twbs',
|
122
159
|
'add:twbs',
|
123
|
-
'Twitter Bootstrap
|
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'
|
124
168
|
)
|
125
169
|
|
126
170
|
def self.exit_on_failure?
|
@@ -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
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../test_helper'
|
4
|
+
|
5
|
+
class GenerateClassicTest < IntegrationTestCase
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
7
|
+
# rubocop:disable Metrics/AbcSize
|
8
|
+
def test_generate_classic
|
9
|
+
run_hoboken(:generate) do
|
10
|
+
assert_file '.env'
|
11
|
+
assert_file 'Gemfile'
|
12
|
+
assert_file('Procfile')
|
13
|
+
assert_file 'README.md'
|
14
|
+
assert_file 'Rakefile'
|
15
|
+
assert_file 'app.rb', /require 'sinatra'/
|
16
|
+
assert_file 'app.rb', %r{require 'sinatra/flash'}
|
17
|
+
assert_file 'app.rb', %r{require 'sinatra/asset_pipeline'}
|
18
|
+
assert_file 'app.rb', /require 'erubi'/
|
19
|
+
assert_file 'app.rb', /erb :index/
|
20
|
+
assert_file_does_not_have_content 'app.rb', /json message:/
|
21
|
+
assert_file 'bin/console'
|
22
|
+
assert_file 'bin/server'
|
23
|
+
assert_file 'bin/setup'
|
24
|
+
assert_file 'config.ru', /run Sinatra::Application/
|
25
|
+
assert_file 'config/environment.rb', /set :erb, { escape_html: true }/
|
26
|
+
assert_file 'config/environment.rb', /require 'better_errors'/
|
27
|
+
assert_directory 'assets'
|
28
|
+
assert_directory 'public'
|
29
|
+
assert_directory 'test'
|
30
|
+
assert_file 'views/index.erb'
|
31
|
+
assert_file 'views/layout.erb', /styled_flash/
|
32
|
+
end
|
33
|
+
end
|
34
|
+
# rubocop:enable Metrics/MethodLength
|
35
|
+
# rubocop:enable Metrics/AbcSize
|
36
|
+
|
37
|
+
def test_generate_classic_tiny
|
38
|
+
run_hoboken(:generate, tiny: true) do
|
39
|
+
assert_file 'app.rb', /__END__/, /@@layout/, /@@index/
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_generate_classic_api_only
|
44
|
+
run_hoboken(:generate, api_only: true) do
|
45
|
+
refute_directory('public')
|
46
|
+
refute_directory('views')
|
47
|
+
assert_file 'app.rb', %r{require 'sinatra/json'}
|
48
|
+
assert_file 'app.rb', /json message:/
|
49
|
+
assert_file_does_not_have_content 'app.rb', %r{require 'sinatra/flash'}
|
50
|
+
assert_file_does_not_have_content 'app.rb', /erb :index/
|
51
|
+
assert_file_does_not_have_content(
|
52
|
+
'config/environment.rb',
|
53
|
+
/set :erb, { escape_html: true }/
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_generate_api_only_with_tiny
|
59
|
+
run_hoboken(:generate, api_only: true, tiny: true) do
|
60
|
+
assert_file_does_not_have_content 'app.rb', /__END__/, /@@layout/, /@@index/
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_generate_with_ruby_version
|
65
|
+
run_hoboken(:generate, run_tests: false, rubocop: false, ruby_version: '2.1.0') do
|
66
|
+
assert_file 'Gemfile', /ruby '2\.1\.0'/
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_generate_with_git
|
71
|
+
run_hoboken(:generate, run_tests: false, rubocop: false, git: true) do
|
72
|
+
assert_directory '.git'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../test_helper'
|
4
|
+
|
5
|
+
class GenerateModularTest < IntegrationTestCase
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
7
|
+
# rubocop:disable Metrics/AbcSize
|
8
|
+
def test_generate_modular
|
9
|
+
run_hoboken(:generate, type: :modular) do
|
10
|
+
assert_file '.env'
|
11
|
+
assert_file 'Gemfile'
|
12
|
+
assert_file('Procfile')
|
13
|
+
assert_file 'README.md'
|
14
|
+
assert_file 'Rakefile'
|
15
|
+
assert_file('app.rb', %r{require 'sinatra/base'})
|
16
|
+
assert_file 'app.rb', %r{require 'sinatra/flash'}
|
17
|
+
assert_file('app.rb', /require 'erubi'/)
|
18
|
+
assert_file('app.rb', /module Sample/)
|
19
|
+
assert_file('app.rb', /class App < Sinatra::Base/)
|
20
|
+
assert_file 'bin/console'
|
21
|
+
assert_file 'bin/server'
|
22
|
+
assert_file 'bin/setup'
|
23
|
+
assert_file 'config.ru', /run Sample::App/
|
24
|
+
assert_file 'config/environment.rb', /set :erb, { escape_html: true }/
|
25
|
+
assert_file 'config/environment.rb', /register Sinatra::Flash/
|
26
|
+
assert_file 'config/environment.rb', /require 'better_errors'/
|
27
|
+
assert_directory 'public'
|
28
|
+
assert_file 'test/support/rack_helpers.rb', /Sample::App/
|
29
|
+
assert_file 'views/index.erb'
|
30
|
+
assert_file 'views/layout.erb', /styled_flash/
|
31
|
+
end
|
32
|
+
end
|
33
|
+
# rubocop:enable Metrics/MethodLength
|
34
|
+
# rubocop:enable Metrics/AbcSize
|
35
|
+
|
36
|
+
def test_generate_modular_tiny
|
37
|
+
# FIXME: For some reason modular apps can't find the inline templates even
|
38
|
+
# if `enable :inline_templates is set. This is a bit of an edge case since
|
39
|
+
# most apps with inline templates are of the classic variety.
|
40
|
+
run_hoboken(:generate, run_tests: false, tiny: true, type: :modular) do
|
41
|
+
assert_file 'app.rb', /__END__/, /@@layout/, /@@index/
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# rubocop:disable Metrics/MethodLength
|
46
|
+
def test_generate_modular_api_only
|
47
|
+
run_hoboken(:generate, type: :modular, api_only: true) do
|
48
|
+
refute_directory('public')
|
49
|
+
refute_directory('views')
|
50
|
+
assert_file 'app.rb', %r{require 'sinatra/json'}
|
51
|
+
assert_file 'app.rb', /json message:/
|
52
|
+
assert_file_does_not_have_content 'app.rb', /erb :index/
|
53
|
+
|
54
|
+
assert_file_does_not_have_content(
|
55
|
+
'config/environment.rb',
|
56
|
+
%r{require 'sinatra/flash'}
|
57
|
+
)
|
58
|
+
|
59
|
+
assert_file_does_not_have_content(
|
60
|
+
'config/environment.rb',
|
61
|
+
/register Sinatra::Flash/
|
62
|
+
)
|
63
|
+
|
64
|
+
assert_file_does_not_have_content(
|
65
|
+
'config/environment.rb',
|
66
|
+
/set :erb, { escape_html: true }/
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
# rubocop:enable Metrics/MethodLength
|
71
|
+
|
72
|
+
def test_generate_with_ruby_version
|
73
|
+
run_hoboken(:generate, run_tests: false, rubocop: false, ruby_version: '2.1.0') do
|
74
|
+
assert_file 'Gemfile', /ruby '2\.1\.0'/
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_generate_with_git
|
79
|
+
run_hoboken(:generate, run_tests: false, rubocop: false, git: true) do
|
80
|
+
assert_directory '.git'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../test_helper'
|
4
|
+
|
5
|
+
class GitHubActionTest < IntegrationTestCase
|
6
|
+
def test_github_action_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:github_action")
|
10
|
+
assert_file('.github/workflows/ruby.yml')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../test_helper'
|
4
|
+
|
5
|
+
class HerokuTest < IntegrationTestCase
|
6
|
+
def test_heroku_add_on
|
7
|
+
run_hoboken(:generate, run_tests: false) do
|
8
|
+
bin_path = File.expand_path('../../bin/hoboken', __dir__)
|
9
|
+
execute("#{bin_path} add:heroku")
|
10
|
+
assert_file('.slugignore')
|
11
|
+
assert_file('config.ru', /\$stdout.sync = true/)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../test_helper'
|
4
|
+
|
5
|
+
class InternationalizationTest < IntegrationTestCase
|
6
|
+
def test_internationalization_add_on_classic
|
7
|
+
run_hoboken(:generate) do
|
8
|
+
bin_path = File.expand_path('../../bin/hoboken', __dir__)
|
9
|
+
execute("#{bin_path} add:i18n")
|
10
|
+
assert_file('Gemfile', 'sinatra-r18n')
|
11
|
+
assert_file('app.rb', "require 'sinatra/r18n'")
|
12
|
+
assert_file('i18n/en.yml')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_internationalization_add_on_modular
|
17
|
+
run_hoboken(:generate, type: :modular) do
|
18
|
+
bin_path = File.expand_path('../../bin/hoboken', __dir__)
|
19
|
+
execute("#{bin_path} add:i18n")
|
20
|
+
assert_file('Gemfile', 'sinatra-r18n')
|
21
|
+
assert_file('app.rb', "require 'sinatra/r18n'")
|
22
|
+
assert_file('config/environment.rb', 'register Sinatra::R18n')
|
23
|
+
assert_file('i18n/en.yml')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|