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.
- checksums.yaml +5 -5
- 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/.github/dependabot.yml +7 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +41 -0
- data/.ruby-version +1 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +131 -0
- data/CODE_OF_CONDUCT.md +8 -0
- data/CONTRIBUTING.md +16 -0
- data/Gemfile +2 -0
- data/IDEAS.md +57 -0
- data/LICENSE.txt +1 -1
- data/README.md +28 -17
- data/Rakefile +14 -8
- data/bin/hoboken +2 -1
- data/hoboken.gemspec +63 -16
- data/lib/hoboken/actions.rb +11 -6
- data/lib/hoboken/add_ons/active_record.rb +142 -0
- data/lib/hoboken/add_ons/airbrake.rb +64 -0
- data/lib/hoboken/add_ons/github_action.rb +14 -0
- data/lib/hoboken/add_ons/heroku.rb +29 -0
- data/lib/hoboken/add_ons/internationalization.rb +28 -0
- data/lib/hoboken/add_ons/metrics.rb +60 -0
- data/lib/hoboken/add_ons/omniauth.rb +174 -0
- data/lib/hoboken/add_ons/rubocop.rb +46 -0
- data/lib/hoboken/add_ons/sequel.rb +135 -0
- data/lib/hoboken/add_ons/sidekiq.rb +137 -0
- data/lib/hoboken/add_ons/travis.rb +15 -0
- data/lib/hoboken/add_ons/turnip.rb +109 -0
- data/lib/hoboken/add_ons/twbs.rb +50 -0
- data/lib/hoboken/add_ons/vcr.rb +54 -0
- data/lib/hoboken/generate.rb +146 -46
- data/lib/hoboken/templates/Gemfile.erb.tt +43 -8
- data/lib/hoboken/templates/README.md.tt +117 -35
- data/lib/hoboken/templates/Rakefile.tt +20 -16
- 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 +25 -11
- data/lib/hoboken/templates/classic_environment.rb.tt +51 -0
- data/lib/hoboken/templates/config.ru.tt +4 -2
- data/lib/hoboken/templates/console +19 -0
- data/lib/hoboken/templates/db.rb.tt +24 -0
- data/lib/hoboken/templates/example_worker.rb.tt +14 -0
- data/lib/hoboken/templates/github_action.tt +28 -0
- data/lib/hoboken/templates/gitignore +8 -0
- data/lib/hoboken/templates/metrics.rake.tt +12 -9
- data/lib/hoboken/templates/modular.rb.tt +28 -15
- data/lib/hoboken/templates/modular_environment.rb.tt +62 -0
- data/lib/hoboken/templates/puma.rb.tt +21 -0
- data/lib/hoboken/templates/rspec.rake.tt +9 -0
- data/lib/hoboken/templates/rubocop.yml.tt +51 -0
- data/lib/hoboken/templates/seeds.rb +12 -0
- data/lib/hoboken/templates/sequel.rake +21 -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 +13 -0
- data/lib/hoboken/templates/spec/example_worker_spec.rb.tt +16 -0
- data/lib/hoboken/templates/spec/rack_matchers.rb.tt +58 -0
- data/lib/hoboken/templates/spec/spec_helper.rb.tt +37 -0
- 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_helpers.rb.tt +55 -0
- data/lib/hoboken/templates/support/rack_test_assertions.rb.tt +113 -0
- data/lib/hoboken/templates/test/test_helper.rb.tt +47 -0
- data/lib/hoboken/templates/test/unit/app_test.rb.tt +11 -3
- data/lib/hoboken/templates/test/unit/example_worker_test.rb.tt +20 -0
- data/lib/hoboken/templates/test_unit.rake.tt +18 -0
- data/lib/hoboken/templates/vcr_setup.rb.tt +15 -0
- data/lib/hoboken/templates/views/index.erb.tt +11 -4
- data/lib/hoboken/templates/views/layout.erb.tt +7 -4
- data/lib/hoboken/version.rb +3 -1
- data/lib/hoboken.rb +147 -325
- data/test/fixtures/Gemfile +3 -3
- data/test/fixtures/Gemfile.pristine +3 -2
- 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 +109 -0
- data/test/unit/hoboken_actions_test.rb +82 -53
- 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 +655 -29
- data/lib/hoboken/templates/sprockets.rake +0 -33
- data/lib/hoboken/templates/sprockets_chain.rb +0 -26
- data/lib/hoboken/templates/sprockets_helper.rb +0 -13
- data/lib/hoboken/templates/test/support/rack_test_assertions.rb.tt +0 -79
- data/lib/hoboken/templates/test/unit/test_helper.rb.tt +0 -36
@@ -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
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
|
5
|
+
require 'warning'
|
6
|
+
|
7
|
+
# Ignore all warnings in Gem dependencies
|
8
|
+
Gem.path.each { |path| Warning.ignore(//, path) }
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
require 'fileutils'
|
12
|
+
|
13
|
+
# rubocop:disable Style/GlobalVars
|
14
|
+
$hoboken_counter = 0
|
15
|
+
DESTINATION = File.expand_path('tmp', __dir__)
|
16
|
+
FileUtils.rm_rf(DESTINATION)
|
17
|
+
|
18
|
+
class IntegrationTestCase < Test::Unit::TestCase
|
19
|
+
def teardown
|
20
|
+
if passed?
|
21
|
+
FileUtils.rm_rf("#{DESTINATION}/#{$hoboken_counter}")
|
22
|
+
else
|
23
|
+
puts "Left #{DESTINATION}/#{$hoboken_counter}/sample in place since test failed."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def run_hoboken(command, **opts)
|
28
|
+
options = extract_cli_options(opts)
|
29
|
+
check_rubocop = opts.fetch(:rubocop, true)
|
30
|
+
run_app_tests_or_specs = opts.fetch(:run_tests, true)
|
31
|
+
|
32
|
+
$hoboken_counter += 1
|
33
|
+
bin_path = File.expand_path('../bin/hoboken', __dir__)
|
34
|
+
|
35
|
+
# rubocop:disable Layout/LineLength
|
36
|
+
`#{bin_path} #{command} #{DESTINATION}/#{$hoboken_counter}/sample #{options.join(' ')}`
|
37
|
+
# rubocop:enable Layout/LineLength
|
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
|
42
|
+
end
|
43
|
+
|
44
|
+
def execute(command)
|
45
|
+
FileUtils.cd("#{DESTINATION}/#{$hoboken_counter}/sample") do
|
46
|
+
`#{command}`
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def assert_file(filename, *contents)
|
51
|
+
full_path = File.join(DESTINATION, $hoboken_counter.to_s, 'sample', filename)
|
52
|
+
assert_block("expected #{filename.inspect} to exist") do
|
53
|
+
File.exist?(full_path)
|
54
|
+
end
|
55
|
+
|
56
|
+
return if contents.empty?
|
57
|
+
|
58
|
+
read = File.read(full_path)
|
59
|
+
contents.each do |content|
|
60
|
+
assert_block("expected #{filename.inspect} to contain #{content}:\n#{read}") do
|
61
|
+
pattern = content.is_a?(Regexp) ? content : Regexp.new(Regexp.quote(content))
|
62
|
+
read =~ pattern
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def assert_file_does_not_have_content(filename, *contents)
|
68
|
+
full_path = File.join(DESTINATION, $hoboken_counter.to_s, 'sample', filename)
|
69
|
+
assert_block("expected #{filename.inspect} to exist") do
|
70
|
+
File.exist?(full_path)
|
71
|
+
end
|
72
|
+
|
73
|
+
read = File.read(full_path)
|
74
|
+
contents.each do |content|
|
75
|
+
assert_block("expected #{filename.inspect} to not contain #{content}:\n#{read}") do
|
76
|
+
pattern = content.is_a?(Regexp) ? content : Regexp.new(Regexp.quote(content))
|
77
|
+
read !~ pattern
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def assert_directory(name)
|
83
|
+
assert_block("expected #{name} directory to exist") do
|
84
|
+
File.directory?(File.join(DESTINATION, $hoboken_counter.to_s, 'sample', name))
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def refute_directory(name)
|
89
|
+
assert_block("did not expect directory #{name} to exist") do
|
90
|
+
!File.directory?(File.join(DESTINATION, $hoboken_counter.to_s, 'sample', name))
|
91
|
+
end
|
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
|
108
|
+
end
|
109
|
+
# rubocop:enable Style/GlobalVars
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../test_helper'
|
4
|
+
require_relative '../../lib/hoboken/actions'
|
3
5
|
|
4
6
|
module Hoboken
|
5
|
-
require
|
7
|
+
require 'thor'
|
6
8
|
class Target < Thor::Group
|
7
9
|
include Thor::Actions
|
8
10
|
include Hoboken::Actions
|
@@ -12,80 +14,107 @@ module Hoboken
|
|
12
14
|
attr_reader :gemfile_path, :gemfile, :target
|
13
15
|
|
14
16
|
def setup
|
15
|
-
@gemfile_path = File.join(
|
16
|
-
@gemfile = File.join(gemfile_path,
|
17
|
+
@gemfile_path = File.join('test', 'fixtures')
|
18
|
+
@gemfile = File.join(gemfile_path, 'Gemfile')
|
17
19
|
@target = Target.new([], {}, destination_root: gemfile_path)
|
18
|
-
FileUtils.copy(File.join(gemfile_path,
|
20
|
+
FileUtils.copy(File.join(gemfile_path, 'Gemfile.pristine'), gemfile)
|
19
21
|
end
|
20
22
|
|
21
23
|
def test_gem_appends_to_gemfile
|
22
|
-
target.gem
|
24
|
+
target.gem 'sinatra', verbose: false
|
25
|
+
expected =
|
26
|
+
"source 'https://rubygems.org'\n" \
|
27
|
+
"ruby '2.0.0'\n\n" \
|
28
|
+
"gem 'sinatra'\n"
|
29
|
+
|
30
|
+
assert_equal(expected, File.read(gemfile))
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_gem_with_version
|
34
|
+
target.gem 'sinatra', version: '1.4.4', verbose: false
|
23
35
|
expected =
|
24
|
-
"source
|
25
|
-
"ruby
|
26
|
-
"gem
|
36
|
+
"source 'https://rubygems.org'\n" \
|
37
|
+
"ruby '2.0.0'\n\n" \
|
38
|
+
"gem 'sinatra', '~> 1.4.4'\n"
|
39
|
+
|
40
|
+
assert_equal(expected, File.read(gemfile))
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_get_with_blank_version
|
44
|
+
target.gem 'sinatra', version: '', verbose: false
|
45
|
+
expected =
|
46
|
+
"source 'https://rubygems.org'\n" \
|
47
|
+
"ruby '2.0.0'\n\n" \
|
48
|
+
"gem 'sinatra'\n"
|
27
49
|
|
28
50
|
assert_equal(expected, File.read(gemfile))
|
29
51
|
end
|
30
52
|
|
31
53
|
def test_gem_with_group
|
32
|
-
target.gem
|
54
|
+
target.gem 'sinatra', version: '1.4.4', group: :test, verbose: false
|
33
55
|
expected =
|
34
|
-
"source
|
35
|
-
"ruby
|
36
|
-
"gem
|
56
|
+
"source 'https://rubygems.org'\n" \
|
57
|
+
"ruby '2.0.0'\n\n" \
|
58
|
+
"gem 'sinatra', '~> 1.4.4', group: :test\n"
|
37
59
|
|
38
60
|
assert_equal(expected, File.read(gemfile))
|
39
61
|
end
|
40
62
|
|
41
63
|
def test_gem_with_multiple_groups
|
42
|
-
target.gem
|
64
|
+
target.gem 'sinatra', version: '1.4.4', group: %i[test development], verbose: false
|
43
65
|
expected =
|
44
|
-
"source
|
45
|
-
"ruby
|
46
|
-
"gem
|
66
|
+
"source 'https://rubygems.org'\n" \
|
67
|
+
"ruby '2.0.0'\n\n" \
|
68
|
+
"gem 'sinatra', '~> 1.4.4', group: [:test, :development]\n"
|
47
69
|
|
48
70
|
assert_equal(expected, File.read(gemfile))
|
49
71
|
end
|
50
72
|
|
51
73
|
def test_gem_with_require
|
52
|
-
target.gem
|
74
|
+
target.gem 'sinatra', version: '1.4.4', require: false, verbose: false
|
53
75
|
expected =
|
54
|
-
"source
|
55
|
-
"ruby
|
56
|
-
"gem
|
76
|
+
"source 'https://rubygems.org'\n" \
|
77
|
+
"ruby '2.0.0'\n\n" \
|
78
|
+
"gem 'sinatra', '~> 1.4.4', require: false\n"
|
57
79
|
|
58
80
|
assert_equal(expected, File.read(gemfile))
|
59
81
|
end
|
60
82
|
|
61
83
|
def test_gem_with_require_and_group
|
62
|
-
target.gem
|
84
|
+
target.gem 'sinatra', version: '1.4.4', require: false, group: :test, verbose: false
|
63
85
|
expected =
|
64
|
-
"source
|
65
|
-
"ruby
|
66
|
-
"gem
|
86
|
+
"source 'https://rubygems.org'\n" \
|
87
|
+
"ruby '2.0.0'\n\n" \
|
88
|
+
"gem 'sinatra', '~> 1.4.4', require: false, group: :test\n"
|
67
89
|
|
68
90
|
assert_equal(expected, File.read(gemfile))
|
69
91
|
end
|
70
92
|
|
71
93
|
def test_gem_with_require_and_multiple_groups
|
72
|
-
target.gem
|
94
|
+
target.gem(
|
95
|
+
'sinatra',
|
96
|
+
version: '1.4.4',
|
97
|
+
require: false,
|
98
|
+
group: %i[test development],
|
99
|
+
verbose: false
|
100
|
+
)
|
101
|
+
|
73
102
|
expected =
|
74
|
-
"source
|
75
|
-
"ruby
|
76
|
-
"gem
|
103
|
+
"source 'https://rubygems.org'\n" \
|
104
|
+
"ruby '2.0.0'\n\n" \
|
105
|
+
"gem 'sinatra', '~> 1.4.4', require: false, group: [:test, :development]\n"
|
77
106
|
|
78
107
|
assert_equal(expected, File.read(gemfile))
|
79
108
|
end
|
80
109
|
|
81
110
|
def test_gem_multiple
|
82
|
-
target.gem
|
83
|
-
target.gem
|
111
|
+
target.gem 'sinatra', version: '1.4.4', verbose: false
|
112
|
+
target.gem 'thin', version: '1.4.4', verbose: false
|
84
113
|
expected =
|
85
|
-
"source
|
86
|
-
"ruby
|
87
|
-
"gem
|
88
|
-
"gem
|
114
|
+
"source 'https://rubygems.org'\n" \
|
115
|
+
"ruby '2.0.0'\n\n" \
|
116
|
+
"gem 'sinatra', '~> 1.4.4'\n" \
|
117
|
+
"gem 'thin', '~> 1.4.4'\n"
|
89
118
|
|
90
119
|
assert_equal(expected, File.read(gemfile))
|
91
120
|
end
|
@@ -96,32 +125,32 @@ module Hoboken
|
|
96
125
|
|
97
126
|
def setup
|
98
127
|
@target = Target.new
|
99
|
-
@text =
|
128
|
+
@text = <<~TEXT
|
100
129
|
|
101
|
-
This is some
|
102
|
-
text that needs
|
103
|
-
to be indented.
|
104
|
-
TEXT
|
130
|
+
This is some
|
131
|
+
text that needs
|
132
|
+
to be indented.
|
133
|
+
TEXT
|
105
134
|
end
|
106
135
|
|
107
136
|
def test_indent_with_one_space
|
108
|
-
expected =
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
TEXT
|
137
|
+
expected = <<~TEXT
|
138
|
+
#{' '}
|
139
|
+
This is some
|
140
|
+
text that needs
|
141
|
+
to be indented.
|
142
|
+
TEXT
|
114
143
|
|
115
144
|
assert_equal(expected, target.indent(text, 1))
|
116
145
|
end
|
117
146
|
|
118
147
|
def test_indent_with_two_spaces
|
119
|
-
expected =
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
TEXT
|
148
|
+
expected = <<~TEXT
|
149
|
+
#{' '}
|
150
|
+
This is some
|
151
|
+
text that needs
|
152
|
+
to be indented.
|
153
|
+
TEXT
|
125
154
|
|
126
155
|
assert_equal(expected, target.indent(text, 2))
|
127
156
|
end
|
data/www/Gemfile
ADDED
data/www/README.md
ADDED
data/www/config.rb
ADDED