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
@@ -10,8 +10,8 @@ module Hoboken
|
|
10
10
|
insert_into_file('app.rb', after: %r{require 'sinatra('|/base')}) do
|
11
11
|
"\nrequire 'sinatra/r18n'"
|
12
12
|
end
|
13
|
-
insert_into_file('
|
14
|
-
"\n
|
13
|
+
insert_into_file('config/environment.rb', after: /register Sinatra::Flash/) do
|
14
|
+
"\n register Sinatra::R18n"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -28,7 +28,7 @@ module Hoboken
|
|
28
28
|
return unless rspec?
|
29
29
|
|
30
30
|
insert_into_file 'spec/spec_helper.rb', before: snippet_location do
|
31
|
-
snippet('
|
31
|
+
snippet('spec')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -44,6 +44,7 @@ module Hoboken
|
|
44
44
|
SimpleCov.start do
|
45
45
|
add_filter '/bin/'
|
46
46
|
add_filter '/config/'
|
47
|
+
add_filter '/db/migrate/'
|
47
48
|
add_filter '/#{framework_folder}/'
|
48
49
|
coverage_dir 'tmp/coverage'
|
49
50
|
end
|
@@ -52,7 +53,7 @@ module Hoboken
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def snippet_location
|
55
|
-
%r{
|
56
|
+
%r{require_relative '\.\./config/environment'}
|
56
57
|
end
|
57
58
|
end
|
58
59
|
end
|
@@ -24,8 +24,9 @@ module Hoboken
|
|
24
24
|
end
|
25
25
|
CODE
|
26
26
|
|
27
|
-
indentation = classic? ? 2 :
|
28
|
-
|
27
|
+
indentation = classic? ? 2 : 6
|
28
|
+
location = /use Rack::Session::Cookie.+\n/
|
29
|
+
insert_into_file('config/environment.rb', after: location) do
|
29
30
|
"\n#{indent(snippet, indentation)}\n"
|
30
31
|
end
|
31
32
|
end
|
@@ -104,12 +105,12 @@ module Hoboken
|
|
104
105
|
append_file('spec/app_spec.rb') do
|
105
106
|
<<~CODE
|
106
107
|
|
107
|
-
# rubocop:disable
|
108
|
+
# rubocop:disable Metrics/BlockLength
|
108
109
|
RSpec.describe 'omniauth', rack: true do
|
109
|
-
before
|
110
|
+
before { OmniAuth.config.test_mode = true }
|
110
111
|
|
111
112
|
describe 'GET /login' do
|
112
|
-
before
|
113
|
+
before { get '/login' }
|
113
114
|
|
114
115
|
it { expect(last_response).to have_http_status(:ok) }
|
115
116
|
it { expect(last_response).to have_content_type(:html) }
|
@@ -131,7 +132,7 @@ module Hoboken
|
|
131
132
|
}
|
132
133
|
end
|
133
134
|
|
134
|
-
before
|
135
|
+
before do
|
135
136
|
OmniAuth.config.mock_auth[:#{provider}] = auth_hash
|
136
137
|
get '/auth/#{provider}/callback'
|
137
138
|
end
|
@@ -145,7 +146,7 @@ module Hoboken
|
|
145
146
|
end
|
146
147
|
|
147
148
|
describe 'GET /auth/failure' do
|
148
|
-
before
|
149
|
+
before do
|
149
150
|
OmniAuth.config.mock_auth[:#{provider}] = :invalid_credentials
|
150
151
|
get '/auth/failure'
|
151
152
|
end
|
@@ -153,7 +154,7 @@ module Hoboken
|
|
153
154
|
it { expect(last_response).to have_http_status(:not_authorized) }
|
154
155
|
end
|
155
156
|
end
|
156
|
-
# rubocop:enable
|
157
|
+
# rubocop:enable Metrics/BlockLength
|
157
158
|
CODE
|
158
159
|
end
|
159
160
|
end
|
@@ -7,8 +7,10 @@ module Hoboken
|
|
7
7
|
class Rubocop < ::Hoboken::Group
|
8
8
|
def add_gems
|
9
9
|
gem 'rubocop', version: '1.12', group: %i[development test]
|
10
|
+
gem 'rubocop-performance', version: '1.13', group: %i[development test]
|
10
11
|
gem 'rubocop-rake', version: '0.5', group: %i[development test]
|
11
12
|
gem 'rubocop-rspec', version: '2.2', group: %i[development test] if rspec?
|
13
|
+
gem 'rubocop-sequel', version: '0.2', group: %i[development test] if sequel?
|
12
14
|
end
|
13
15
|
|
14
16
|
def rubocop_yml
|
@@ -20,16 +22,20 @@ module Hoboken
|
|
20
22
|
<<~TEXT
|
21
23
|
# frozen_string_literal: true
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
begin
|
26
|
+
require 'rubocop/rake_task'
|
27
|
+
RuboCop::RakeTask.new
|
28
|
+
# rubocop:disable Lint/SuppressedException
|
29
|
+
rescue LoadError
|
30
|
+
end
|
31
|
+
# rubocop:enable Lint/SuppressedException
|
26
32
|
TEXT
|
27
33
|
end
|
28
34
|
end
|
29
35
|
|
30
36
|
def ci_task
|
31
37
|
task_list = if rspec?
|
32
|
-
'%w[
|
38
|
+
'%w[spec rubocop]'
|
33
39
|
else
|
34
40
|
"['test:all', 'rubocop']"
|
35
41
|
end
|
@@ -8,6 +8,7 @@ module Hoboken
|
|
8
8
|
def add_gems
|
9
9
|
gem 'sequel', version: '5.43'
|
10
10
|
gem 'sqlite3', version: '1.4', group: %i[development test]
|
11
|
+
gem 'rubocop-sequel', version: '0.2', group: %i[development test] if rubocop?
|
11
12
|
end
|
12
13
|
|
13
14
|
def setup_directories
|
@@ -25,9 +26,9 @@ module Hoboken
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def require_db_config
|
28
|
-
location =
|
29
|
-
insert_into_file('
|
30
|
-
"require_relative '
|
29
|
+
location = %r{require_relative '\.\./app'}
|
30
|
+
insert_into_file('config/environment.rb', before: location) do
|
31
|
+
"require_relative 'db'\n\n"
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
@@ -49,26 +50,20 @@ module Hoboken
|
|
49
50
|
"\nrequire 'sequel'"
|
50
51
|
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
CODE
|
53
|
+
snippet = <<~CODE
|
54
|
+
def run(*args, &block)
|
55
|
+
result = nil
|
56
|
+
DB.transaction(rollback: :always) { result = super }
|
57
|
+
result
|
58
|
+
end
|
59
|
+
CODE
|
60
|
+
|
61
|
+
insert_into_file('test/test_helper.rb', after: /include RackHelpers\n/) do
|
62
|
+
"\n#{indent(snippet, 6)}"
|
67
63
|
end
|
68
64
|
end
|
69
65
|
# rubocop:enable Metrics/MethodLength
|
70
66
|
|
71
|
-
# rubocop:disable Metrics/MethodLength
|
72
67
|
def add_database_spec_helper
|
73
68
|
return unless rspec?
|
74
69
|
|
@@ -76,21 +71,52 @@ module Hoboken
|
|
76
71
|
"ENV['DATABASE_URL'] = 'sqlite://db/test.db'\n"
|
77
72
|
end
|
78
73
|
|
79
|
-
|
80
|
-
config.around
|
81
|
-
DB.transaction(rollback: :always) { example.run }
|
82
|
-
end
|
83
|
-
CODE
|
84
|
-
|
85
|
-
snippet_database = <<~CODE
|
86
|
-
config.around(:example, database: true) do |example|
|
74
|
+
snippet = <<~CODE
|
75
|
+
config.around do |example|
|
87
76
|
DB.transaction(rollback: :always) { example.run }
|
88
77
|
end
|
89
78
|
CODE
|
90
79
|
|
91
80
|
location = /RSpec\.configure do \|config\|\n/
|
92
81
|
insert_into_file('spec/spec_helper.rb', after: location) do
|
93
|
-
"#{indent(
|
82
|
+
"#{indent(snippet, 2)}\n"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def update_rubocop_config
|
87
|
+
return unless rubocop?
|
88
|
+
|
89
|
+
insert_into_file('.rubocop.yml', after: /require:\n/) do
|
90
|
+
" - rubocop-sequel\n"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# rubocop:disable Metrics/MethodLength
|
95
|
+
def update_readme
|
96
|
+
snippet = <<~CODE
|
97
|
+
<tr>
|
98
|
+
<td>DATABASE_URL</td>
|
99
|
+
<td>Yes</td>
|
100
|
+
<td>
|
101
|
+
`sqlite://db/test.db` (for the test environment <em>only</em>)
|
102
|
+
</td>
|
103
|
+
<td>
|
104
|
+
Connection URL to the database. The format varies according
|
105
|
+
database adapter. Refer to the
|
106
|
+
<a href="https://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html">
|
107
|
+
Sequel gem documentation</a> for more information. Some examples:
|
108
|
+
<dl>
|
109
|
+
<dt>Sqlite3</dt>
|
110
|
+
<dd>`sqlite://db/development.db`</dd>
|
111
|
+
<dt>PostgreSQL</dt>
|
112
|
+
<dd>`postgresql://localhost/myapp_development?pool=5`</dd>
|
113
|
+
</dl>
|
114
|
+
</td>
|
115
|
+
</tr>
|
116
|
+
CODE
|
117
|
+
|
118
|
+
insert_into_file('README.md', after: /<tbody>\n/) do
|
119
|
+
indent(snippet, 8)
|
94
120
|
end
|
95
121
|
end
|
96
122
|
# rubocop:enable Metrics/MethodLength
|
@@ -98,7 +124,7 @@ module Hoboken
|
|
98
124
|
def reminders
|
99
125
|
say "\nGemfile updated... don't forget to 'bundle install'"
|
100
126
|
say <<~TEXT
|
101
|
-
|
127
|
+
|
102
128
|
Notes:
|
103
129
|
* The sqlite3 gem has been installed for dev and test environments only. You will need to specify a gem to use for production.
|
104
130
|
* You will need to specify an environment variable 'DATABASE_URL' (either add it to .env or export it)
|
@@ -0,0 +1,137 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hoboken
|
4
|
+
module AddOns
|
5
|
+
# Background processing via the Sidekiq gem.
|
6
|
+
#
|
7
|
+
class Sidekiq < ::Hoboken::Group
|
8
|
+
def add_gems
|
9
|
+
gem 'sidekiq', version: '6.2'
|
10
|
+
end
|
11
|
+
|
12
|
+
def adjust_rackup_config
|
13
|
+
gsub_file('config.ru', /run .*::App.*\n/) do |match|
|
14
|
+
<<~CODE
|
15
|
+
require 'sidekiq/web'
|
16
|
+
|
17
|
+
if 'production' == ENV.fetch('RACK_ENV', 'production')
|
18
|
+
Sidekiq::Web.use Rack::Auth::Basic do |username, password|
|
19
|
+
[username, password] == [ENV['SIDEKIQ_USERNAME'], ENV['SIDEKIQ_PASSWORD']]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Sidekiq::Web.use Rack::Session::Cookie, secret: ENV['SESSION_SECRET']
|
24
|
+
run Rack::URLMap.new('/' => #{match[4...-1].chomp}, '/sidekiq' => Sidekiq::Web)
|
25
|
+
CODE
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup_config
|
30
|
+
template('hoboken/templates/sidekiq.rb.tt', 'config/sidekiq.rb')
|
31
|
+
location = "require_relative '../app'"
|
32
|
+
insert_into_file('config/environment.rb', before: location) do
|
33
|
+
"require_relative 'sidekiq'\n\n"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def example_worker
|
38
|
+
empty_directory('workers')
|
39
|
+
template('hoboken/templates/example_worker.rb.tt', 'workers/example_worker.rb')
|
40
|
+
end
|
41
|
+
|
42
|
+
def worker_test_and_helper
|
43
|
+
return if rspec?
|
44
|
+
|
45
|
+
insert_into_file('test/test_helper.rb', after: "require 'rack/test'") do
|
46
|
+
"\nrequire 'sidekiq/testing'"
|
47
|
+
end
|
48
|
+
|
49
|
+
template(
|
50
|
+
'hoboken/templates/test/unit/example_worker_test.rb.tt',
|
51
|
+
'test/unit/example_worker_test.rb'
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
# rubocop:disable Metrics/MethodLength
|
56
|
+
def worker_spec_and_helper
|
57
|
+
return unless rspec?
|
58
|
+
|
59
|
+
insert_into_file('spec/spec_helper.rb', after: "require 'rack/test'") do
|
60
|
+
"\nrequire 'sidekiq/testing'"
|
61
|
+
end
|
62
|
+
|
63
|
+
snippet = <<~CODE
|
64
|
+
config.before(:each, sidekiq: true) do
|
65
|
+
Sidekiq::Worker.clear_all
|
66
|
+
end
|
67
|
+
CODE
|
68
|
+
|
69
|
+
location = /RSpec\.configure do \|config\|\n/
|
70
|
+
insert_into_file('spec/spec_helper.rb', after: location) do
|
71
|
+
"#{indent(snippet, 2)}\n"
|
72
|
+
end
|
73
|
+
|
74
|
+
template(
|
75
|
+
'hoboken/templates/spec/example_worker_spec.rb.tt',
|
76
|
+
'spec/example_worker_spec.rb'
|
77
|
+
)
|
78
|
+
end
|
79
|
+
# rubocop:enable Metrics/MethodLength
|
80
|
+
|
81
|
+
def add_worker_to_procfile
|
82
|
+
append_file('Procfile') do
|
83
|
+
"\nworker: bundle exec sidekiq " \
|
84
|
+
'-r ./config/sidekiq.rb ' \
|
85
|
+
'-e $RACK_ENV ' \
|
86
|
+
'-c ${MAX_THREADS:-5} ' \
|
87
|
+
"-v\n"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# rubocop:disable Metrics/MethodLength
|
92
|
+
def update_readme
|
93
|
+
snippet = <<~CODE
|
94
|
+
<tr>
|
95
|
+
<td>REDIS_URL</td>
|
96
|
+
<td>Yes</td>
|
97
|
+
<td>localhost:6379</td>
|
98
|
+
<td>Redis connection URL</td>
|
99
|
+
</tr>
|
100
|
+
<tr>
|
101
|
+
<td>SIDEKIQ_PASSWORD</td>
|
102
|
+
<td>Production Only</td>
|
103
|
+
<td>None</td>
|
104
|
+
<td>Password for SidekiqUI Basic Auth</td>
|
105
|
+
</tr>
|
106
|
+
<tr>
|
107
|
+
<td>SIDEKIQ_USERNAME</td>
|
108
|
+
<td>Production Only</td>
|
109
|
+
<td>None</td>
|
110
|
+
<td>Username for SidekiqUI Basic Auth</td>
|
111
|
+
</tr>
|
112
|
+
CODE
|
113
|
+
|
114
|
+
insert_into_file('README.md', after: /<tbody>\n/) do
|
115
|
+
indent(snippet, 8)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
# rubocop:enable Metrics/MethodLength
|
119
|
+
|
120
|
+
def reminders
|
121
|
+
text = <<~TEXT
|
122
|
+
|
123
|
+
Gemfile updated... don't forget to 'bundle install'
|
124
|
+
|
125
|
+
You can configure a Sidekiq error handing service in `config/sidekiq.rb`.
|
126
|
+
|
127
|
+
Sidekiq UI is available at '/sidekiq'. In production environments
|
128
|
+
the UI is protected with HTTP Basic Auth. Don't forget to set
|
129
|
+
`SIDEKIQ_USERNAME` and `SIDEKIQ_PASSWORD` in your production
|
130
|
+
environment or you won't be able to access the Sidekiq UI.
|
131
|
+
TEXT
|
132
|
+
|
133
|
+
say text, :green
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hoboken
|
4
|
+
module AddOns
|
5
|
+
# Gherkin extension for RSpec
|
6
|
+
#
|
7
|
+
class Turnip < ::Hoboken::Group
|
8
|
+
def add_gems
|
9
|
+
return unless rspec?
|
10
|
+
|
11
|
+
gem 'turnip', version: '4.3', group: :test
|
12
|
+
end
|
13
|
+
|
14
|
+
# rubocop:disable Metrics/MethodLength
|
15
|
+
def add_sample_files
|
16
|
+
return unless rspec?
|
17
|
+
|
18
|
+
empty_directory('spec/features')
|
19
|
+
empty_directory('spec/support/steps')
|
20
|
+
create_file('spec/features/example.feature') do
|
21
|
+
<<~TEXT
|
22
|
+
@feature
|
23
|
+
Feature: An Example
|
24
|
+
This is an example feature spec that can be deleted.
|
25
|
+
|
26
|
+
Scenario: Name of some scenario
|
27
|
+
Given nothing
|
28
|
+
When I do nothing
|
29
|
+
Then nothing should happen
|
30
|
+
TEXT
|
31
|
+
end
|
32
|
+
|
33
|
+
create_file('spec/support/steps/example_steps.rb') do
|
34
|
+
<<~CODE
|
35
|
+
# frozen_string_literal: true
|
36
|
+
|
37
|
+
# Steps for the example feature that can be deleted.
|
38
|
+
|
39
|
+
step 'nothing' do
|
40
|
+
# ...
|
41
|
+
end
|
42
|
+
|
43
|
+
step 'I do nothing' do
|
44
|
+
# ...
|
45
|
+
end
|
46
|
+
|
47
|
+
step 'nothing should happen' do
|
48
|
+
# ...
|
49
|
+
end
|
50
|
+
CODE
|
51
|
+
end
|
52
|
+
end
|
53
|
+
# rubocop:enable Metrics/MethodLength
|
54
|
+
|
55
|
+
def add_helper
|
56
|
+
return unless rspec?
|
57
|
+
|
58
|
+
template(
|
59
|
+
'hoboken/templates/spec/turnip_helper.rb.tt',
|
60
|
+
'spec/turnip_helper.rb'
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
def rake_task
|
65
|
+
return unless rspec?
|
66
|
+
|
67
|
+
create_file('tasks/turnip.rake') do
|
68
|
+
<<~TEXT
|
69
|
+
# frozen_string_literal: true
|
70
|
+
|
71
|
+
require 'rspec/core/rake_task'
|
72
|
+
|
73
|
+
desc 'Run turnip acceptance tests'
|
74
|
+
RSpec::Core::RakeTask.new(:turnip) do |t|
|
75
|
+
t.pattern = './spec{,/*/**}/*.feature'
|
76
|
+
t.rspec_opts = ['-r turnip/rspec']
|
77
|
+
end
|
78
|
+
TEXT
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def default_rake_task
|
83
|
+
return unless rspec?
|
84
|
+
|
85
|
+
gsub_file('Rakefile', /task default:.*/, 'task default: %w[spec turnip]')
|
86
|
+
end
|
87
|
+
|
88
|
+
def ci_task
|
89
|
+
return unless rspec?
|
90
|
+
|
91
|
+
gsub_file('Rakefile', /task ci:.*/) do |match|
|
92
|
+
if match.include?('rubocop')
|
93
|
+
'task ci: %w[spec turnip rubocop]'
|
94
|
+
else
|
95
|
+
'task ci: %w[spec turnip]'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def reminders
|
101
|
+
if rspec?
|
102
|
+
say "Gemfile updated... don't forget to 'bundle install'", :green
|
103
|
+
else
|
104
|
+
say 'Turnip requires RSpec to be setup', :red
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/lib/hoboken/add_ons/twbs.rb
CHANGED
@@ -6,31 +6,26 @@ module Hoboken
|
|
6
6
|
#
|
7
7
|
class TwitterBootstrap < ::Hoboken::Group
|
8
8
|
def add_gem
|
9
|
-
return unless sprockets?
|
10
|
-
|
11
9
|
gem 'bootstrap', version: '5.0.0.beta3', group: :assets
|
12
10
|
end
|
13
11
|
|
14
12
|
def update_app
|
15
|
-
return unless sprockets?
|
16
|
-
|
17
13
|
indentation = classic? ? 2 : 6
|
18
|
-
|
14
|
+
location = /configure do\n/
|
15
|
+
insert_into_file('config/environment.rb', after: location) do
|
19
16
|
indent("require 'bootstrap'\n", indentation)
|
20
17
|
end
|
21
18
|
end
|
22
19
|
|
23
20
|
def update_asset_files
|
24
|
-
|
25
|
-
|
26
|
-
prepend_file('assets/styles.scss') do
|
21
|
+
prepend_file('assets/stylesheets/styles.scss') do
|
27
22
|
<<~CODE
|
28
23
|
@import "bootstrap";
|
29
24
|
|
30
25
|
CODE
|
31
26
|
end
|
32
27
|
|
33
|
-
prepend_file('assets/app.js') do
|
28
|
+
prepend_file('assets/javascripts/app.js') do
|
34
29
|
<<~CODE
|
35
30
|
//= require popper
|
36
31
|
//= require bootstrap-sprockets
|
@@ -38,17 +33,7 @@ module Hoboken
|
|
38
33
|
end
|
39
34
|
end
|
40
35
|
|
41
|
-
def update_sprockets_rake_tasks
|
42
|
-
return unless sprockets?
|
43
|
-
|
44
|
-
insert_into_file('tasks/sprockets.rake', after: /require 'sprockets'\n/) do
|
45
|
-
" require 'bootstrap'\n"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
36
|
def remove_normalize_css
|
50
|
-
return unless sprockets?
|
51
|
-
|
52
37
|
gsub_file(
|
53
38
|
'views/layout.erb',
|
54
39
|
'<link rel="stylesheet" type="text/css" ' \
|
@@ -58,22 +43,7 @@ module Hoboken
|
|
58
43
|
end
|
59
44
|
|
60
45
|
def reminders
|
61
|
-
|
62
|
-
say "\nGemfile updated... don't forget to 'bundle install'"
|
63
|
-
else
|
64
|
-
text = <<~TEXT
|
65
|
-
Sprockets is required. Please install the Sprockets add-on
|
66
|
-
first (hoboken add:sprockets).
|
67
|
-
TEXT
|
68
|
-
|
69
|
-
say text, :red
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
def sprockets?
|
76
|
-
Dir.exist?('assets')
|
46
|
+
say "\nGemfile updated... don't forget to 'bundle install'"
|
77
47
|
end
|
78
48
|
end
|
79
49
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hoboken
|
4
|
+
module AddOns
|
5
|
+
# Record your test suite's HTTP interactions and replay them during
|
6
|
+
# future test runs.
|
7
|
+
#
|
8
|
+
class Vcr < ::Hoboken::Group
|
9
|
+
def add_gems
|
10
|
+
gem 'vcr', version: '6.0', group: :test
|
11
|
+
gem 'webmock', version: '3.13', group: :test
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_directories
|
15
|
+
empty_directory(File.join(location, 'fixtures', 'vcr_cassettes'))
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_setup_file
|
19
|
+
template(
|
20
|
+
'hoboken/templates/vcr_setup.rb.tt',
|
21
|
+
File.join(location, 'support/vcr_setup.rb')
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def require_vcr_in_test_helper
|
26
|
+
return if rspec?
|
27
|
+
|
28
|
+
snippet_location = "require_relative 'support/rack_helpers'"
|
29
|
+
insert_into_file('test/test_helper.rb', after: snippet_location) do
|
30
|
+
"\nrequire_relative 'support/vcr_setup'"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def require_vcr_in_spec_helper
|
35
|
+
return unless rspec?
|
36
|
+
|
37
|
+
snippet_location = "require 'support/rack_helpers'"
|
38
|
+
insert_into_file('spec/spec_helper.rb', after: snippet_location) do
|
39
|
+
"\nrequire 'support/vcr_setup'"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def reminders
|
44
|
+
say "Gemfile updated... don't forget to 'bundle install'", :green
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def location
|
50
|
+
rspec? ? 'spec' : 'test'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|