hoboken 0.0.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +7 -0
  3. data/.github/workflows/ruby.yml +28 -0
  4. data/.rubocop.yml +33 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +2 -0
  7. data/IDEAS.md +57 -0
  8. data/LICENSE.txt +1 -1
  9. data/README.md +21 -10
  10. data/Rakefile +14 -6
  11. data/bin/hoboken +2 -1
  12. data/hoboken.gemspec +53 -16
  13. data/lib/hoboken.rb +110 -23
  14. data/lib/hoboken/actions.rb +10 -6
  15. data/lib/hoboken/add_ons/github_action.rb +14 -0
  16. data/lib/hoboken/add_ons/heroku.rb +8 -23
  17. data/lib/hoboken/add_ons/internationalization.rb +10 -6
  18. data/lib/hoboken/add_ons/metrics.rb +39 -14
  19. data/lib/hoboken/add_ons/omniauth.rb +114 -47
  20. data/lib/hoboken/add_ons/rubocop.rb +40 -0
  21. data/lib/hoboken/add_ons/sequel.rb +76 -47
  22. data/lib/hoboken/add_ons/sprockets.rb +67 -65
  23. data/lib/hoboken/add_ons/travis.rb +6 -2
  24. data/lib/hoboken/add_ons/twbs.rb +80 -0
  25. data/lib/hoboken/generate.rb +112 -38
  26. data/lib/hoboken/templates/Gemfile.erb.tt +33 -10
  27. data/lib/hoboken/templates/README.md.tt +105 -35
  28. data/lib/hoboken/templates/Rakefile.tt +10 -22
  29. data/lib/hoboken/templates/classic.rb.tt +35 -8
  30. data/lib/hoboken/templates/config.ru.tt +5 -3
  31. data/lib/hoboken/templates/console.sh +5 -0
  32. data/lib/hoboken/templates/db.rb.tt +24 -0
  33. data/lib/hoboken/templates/github_action.tt +28 -0
  34. data/lib/hoboken/templates/gitignore +8 -1
  35. data/lib/hoboken/templates/metrics.rake.tt +10 -9
  36. data/lib/hoboken/templates/modular.rb.tt +40 -11
  37. data/lib/hoboken/templates/puma.rb.tt +21 -0
  38. data/lib/hoboken/templates/rspec.rake.tt +5 -0
  39. data/lib/hoboken/templates/rubocop.yml.tt +31 -0
  40. data/lib/hoboken/templates/sequel.rake +6 -4
  41. data/lib/hoboken/templates/server.sh +12 -0
  42. data/lib/hoboken/templates/setup.sh +7 -0
  43. data/lib/hoboken/templates/spec/app_spec.rb.tt +15 -0
  44. data/lib/hoboken/templates/spec/rack_matchers.rb.tt +56 -0
  45. data/lib/hoboken/templates/spec/spec_helper.rb.tt +41 -0
  46. data/lib/hoboken/templates/sprockets.rake +13 -7
  47. data/lib/hoboken/templates/sprockets_chain.rb +7 -3
  48. data/lib/hoboken/templates/sprockets_helper.rb +14 -10
  49. data/lib/hoboken/templates/support/rack_helpers.rb.tt +55 -0
  50. data/lib/hoboken/templates/support/rack_test_assertions.rb.tt +111 -0
  51. data/lib/hoboken/templates/test/test_helper.rb.tt +38 -27
  52. data/lib/hoboken/templates/test/unit/app_test.rb.tt +11 -3
  53. data/lib/hoboken/templates/test_unit.rake.tt +18 -0
  54. data/lib/hoboken/templates/views/index.erb.tt +10 -3
  55. data/lib/hoboken/templates/views/layout.erb.tt +4 -1
  56. data/lib/hoboken/version.rb +3 -1
  57. data/test/fixtures/Gemfile +3 -3
  58. data/test/fixtures/Gemfile.pristine +3 -2
  59. data/test/integration/add_on_test.rb +399 -136
  60. data/test/integration/generate_test.rb +170 -38
  61. data/test/test_helper.rb +54 -23
  62. data/test/unit/hoboken_actions_test.rb +70 -61
  63. metadata +441 -16
  64. data/.travis.yml +0 -5
  65. data/lib/hoboken/templates/test/support/rack_test_assertions.rb.tt +0 -92
@@ -1,71 +1,203 @@
1
- require_relative "../test_helper"
1
+ # frozen_string_literal: true
2
2
 
3
+ require_relative '../test_helper'
4
+
5
+ # rubocop:disable Metrics/ClassLength
3
6
  class GenerateTest < IntegrationTestCase
7
+ # rubocop:disable Metrics/MethodLength
8
+ # rubocop:disable Metrics/AbcSize
4
9
  def test_generate_classic
5
10
  run_hoboken(:generate) do
6
- assert_file ".env"
7
- assert_file "Gemfile"
8
- assert_file "README.md"
9
- assert_file "Rakefile"
10
- assert_file "app.rb", /require "sinatra"/
11
- assert_file "config.ru", /run Sinatra::Application/
12
- assert_directory "public"
13
- assert_directory "test"
14
- assert_file "views/index.erb"
15
- assert_file "views/layout.erb"
11
+ assert_file '.env'
12
+ assert_file 'Gemfile'
13
+ assert_file('Procfile')
14
+ assert_file 'README.md'
15
+ assert_file 'Rakefile'
16
+ assert_file 'app.rb', /require 'sinatra'/
17
+ assert_file 'app.rb', %r{require 'sinatra/flash'}
18
+ assert_file 'app.rb', /require 'erubi'/
19
+ assert_file 'app.rb', /erb :index/
20
+ assert_file 'app.rb', /set :erb, { escape_html: true }/
21
+ assert_file 'app.rb', /require 'better_errors'/
22
+ assert_file_does_not_have_content 'app.rb', /json message:/
23
+ assert_file 'bin/console'
24
+ assert_file 'bin/server'
25
+ assert_file 'bin/setup'
26
+ assert_file 'config.ru', /run Sinatra::Application/
27
+ assert_directory 'public'
28
+ assert_directory 'test'
29
+ assert_file 'views/index.erb'
30
+ assert_file 'views/layout.erb', /styled_flash/
16
31
  end
17
32
  end
33
+ # rubocop:enable Metrics/MethodLength
34
+ # rubocop:enable Metrics/AbcSize
18
35
 
19
36
  def test_generate_classic_tiny
20
37
  run_hoboken(:generate, tiny: true) do
21
- refute_directory("public")
22
- assert_file "app.rb", /__END__/, /@@layout/, /@@index/
38
+ refute_directory('public')
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 'app.rb', /set :erb, { escape_html: true }/
52
+ end
53
+ end
54
+
55
+ def test_generate_api_only_with_tiny
56
+ run_hoboken(:generate, api_only: true, tiny: true) do
57
+ assert_file_does_not_have_content 'app.rb', /__END__/, /@@layout/, /@@index/
58
+ end
59
+ end
60
+
61
+ def test_generate_classic_can_run_tests
62
+ run_hoboken(:generate) do
63
+ result = execute('rake test:all')
64
+ assert_match(/1 tests, 3 assertions, 0 failures, 0 errors/, result)
65
+ end
66
+ end
67
+
68
+ def test_generate_classic_can_run_specs
69
+ run_hoboken(:generate, test_framework: 'rspec') do
70
+ result = execute('rake spec')
71
+ assert_match(/3 examples, 0 failures/, result)
72
+ end
73
+ end
74
+
75
+ def test_generate_classic_api_only_can_run_tests
76
+ run_hoboken(:generate, api_only: true) do
77
+ result = execute('rake test:all')
78
+ assert_match(/1 tests, 3 assertions, 0 failures, 0 errors/, result)
79
+ end
80
+ end
81
+
82
+ def test_generate_classic_api_only_can_run_specs
83
+ run_hoboken(:generate, api_only: true, test_framework: 'rspec') do
84
+ result = execute('rake spec')
85
+ assert_match(/3 examples, 0 failures/, result)
86
+ end
87
+ end
88
+
89
+ def test_generate_classic_passes_rubocop_inspection
90
+ run_hoboken(:generate) do
91
+ assert_match(/no offenses detected/, execute('rubocop'))
23
92
  end
24
93
  end
25
94
 
26
- #def test_generate_classic_can_run_tests
27
- #run_hoboken(:generate) do
28
- #assert_match /1 tests, 1 assertions, 0 failures, 0 errors, 0 skips/, execute("rake test:all")
29
- #end
30
- #end
95
+ def test_generate_classic_api_only_passes_rubocop_inspection
96
+ run_hoboken(:generate, api_only: true) do
97
+ assert_match(/no offenses detected/, execute('rubocop'))
98
+ end
99
+ end
31
100
 
101
+ # rubocop:disable Metrics/MethodLength
102
+ # rubocop:disable Metrics/AbcSize
32
103
  def test_generate_modular
33
104
  run_hoboken(:generate, type: :modular) do
34
- assert_file ".env"
35
- assert_file "Gemfile"
36
- assert_file "README.md"
37
- assert_file "Rakefile"
38
- assert_file "app.rb", /require "sinatra\/base"/, /module Sample/, /class App < Sinatra::Base/
39
- assert_file "config.ru", /run Sample::App/
40
- assert_directory "public"
41
- assert_file "test/test_helper.rb", /Sample::App/
42
- assert_file "views/index.erb"
43
- assert_file "views/layout.erb"
105
+ assert_file '.env'
106
+ assert_file 'Gemfile'
107
+ assert_file('Procfile')
108
+ assert_file 'README.md'
109
+ assert_file 'Rakefile'
110
+ assert_file('app.rb', %r{require 'sinatra/base'})
111
+ assert_file 'app.rb', %r{require 'sinatra/flash'}
112
+ assert_file('app.rb', /require 'erubi'/)
113
+ assert_file('app.rb', /module Sample/)
114
+ assert_file('app.rb', /class App < Sinatra::Base/)
115
+ assert_file 'app.rb', /set :erb, { escape_html: true }/
116
+ assert_file 'app.rb', /register Sinatra::Flash/
117
+ assert_file 'app.rb', /require 'better_errors'/
118
+ assert_file 'bin/console'
119
+ assert_file 'bin/server'
120
+ assert_file 'bin/setup'
121
+ assert_file 'config.ru', /run Sample::App/
122
+ assert_directory 'public'
123
+ assert_file 'test/support/rack_helpers.rb', /Sample::App/
124
+ assert_file 'views/index.erb'
125
+ assert_file 'views/layout.erb', /styled_flash/
44
126
  end
45
127
  end
128
+ # rubocop:enable Metrics/MethodLength
129
+ # rubocop:enable Metrics/AbcSize
46
130
 
47
131
  def test_generate_modular_tiny
48
132
  run_hoboken(:generate, tiny: true, type: :modular) do
49
- refute_directory("public")
50
- assert_file "app.rb", /__END__/, /@@layout/, /@@index/
133
+ refute_directory('public')
134
+ assert_file 'app.rb', /__END__/, /@@layout/, /@@index/
135
+ end
136
+ end
137
+
138
+ def test_generate_modular_api_only
139
+ run_hoboken(:generate, type: :modular, api_only: true) do
140
+ refute_directory('public')
141
+ refute_directory('views')
142
+ assert_file 'app.rb', %r{require 'sinatra/json'}
143
+ assert_file 'app.rb', /json message:/
144
+ assert_file_does_not_have_content 'app.rb', %r{require 'sinatra/flash'}
145
+ assert_file_does_not_have_content 'app.rb', /register Sinatra::Flash/
146
+ assert_file_does_not_have_content 'app.rb', /erb :index/
147
+ assert_file_does_not_have_content 'app.rb', /set :erb, { escape_html: true }/
148
+ end
149
+ end
150
+
151
+ def test_generate_modular_can_run_tests
152
+ run_hoboken(:generate, type: :modular) do
153
+ result = execute('rake test:all')
154
+ assert_match(/1 tests, 3 assertions, 0 failures, 0 errors/, result)
155
+ end
156
+ end
157
+
158
+ def test_generate_modular_can_run_specs
159
+ run_hoboken(:generate, test_framework: 'rspec', type: :modular) do
160
+ result = execute('rake spec')
161
+ assert_match(/3 examples, 0 failures/, result)
51
162
  end
52
163
  end
53
164
 
54
- #def test_generate_modular_can_run_tests
55
- #run_hoboken(:generate, type: :modular) do
56
- #assert_match /1 tests, 1 assertions, 0 failures, 0 errors, 0 skips/, execute("rake test:all")
57
- #end
58
- #end
165
+ def test_generate_modular_api_only_can_run_tests
166
+ run_hoboken(:generate, api_only: true, type: :modular) do
167
+ result = execute('rake test:all')
168
+ assert_match(/1 tests, 3 assertions, 0 failures, 0 errors/, result)
169
+ end
170
+ end
171
+
172
+ def test_generate_modular_api_only_can_run_specs
173
+ run_hoboken(:generate, test_framework: 'rspec', api_only: true, type: :modular) do
174
+ result = execute('rake spec')
175
+ assert_match(/3 examples, 0 failures/, result)
176
+ end
177
+ end
178
+
179
+ def test_generate_modular_passes_rubocop_inspection
180
+ run_hoboken(:generate, type: :modular) do
181
+ assert_match(/no offenses detected/, execute('rubocop'))
182
+ end
183
+ end
184
+
185
+ def test_generate_modular_api_only_passes_rubocop_inspection
186
+ run_hoboken(:generate, api_only: true, type: :modular) do
187
+ assert_match(/no offenses detected/, execute('rubocop'))
188
+ end
189
+ end
59
190
 
60
191
  def test_generate_with_ruby_version
61
- run_hoboken(:generate, ruby_version: "2.1.0") do
62
- assert_file "Gemfile", /ruby "2\.1\.0"/
192
+ run_hoboken(:generate, ruby_version: '2.1.0') do
193
+ assert_file 'Gemfile', /ruby '2\.1\.0'/
63
194
  end
64
195
  end
65
196
 
66
197
  def test_generate_with_git
67
198
  run_hoboken(:generate, git: true) do
68
- assert_directory ".git"
199
+ assert_directory '.git'
69
200
  end
70
201
  end
71
202
  end
203
+ # rubocop:enable Metrics/ClassLength
data/test/test_helper.rb CHANGED
@@ -1,67 +1,98 @@
1
- require "test/unit"
2
- require "fileutils"
1
+ # frozen_string_literal: true
3
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
4
14
  $hoboken_counter = 0
5
- DESTINATION = File.expand_path("../tmp", __FILE__)
15
+ DESTINATION = File.expand_path('tmp', __dir__)
6
16
  FileUtils.rm_rf(DESTINATION)
7
17
 
8
18
  class IntegrationTestCase < Test::Unit::TestCase
9
19
  def teardown
10
- if self.passed?
20
+ if passed?
11
21
  FileUtils.rm_rf("#{DESTINATION}/#{$hoboken_counter}")
12
22
  else
13
23
  puts "Left #{DESTINATION}/#{$hoboken_counter}/sample in place since test failed."
14
24
  end
15
25
  end
16
26
 
27
+ # rubocop:disable Metrics/AbcSize
17
28
  def run_hoboken(command, **opts)
18
- options = Array.new.tap do |o|
19
- o << "--git" if opts.fetch(:git) { false }
20
- o << "--tiny" if opts.fetch(:tiny) { false }
21
- o << "--type=#{opts[:type]}" if opts.has_key?(:type)
22
- o << "--ruby-version=#{opts[:ruby_version]}" if opts.has_key?(:ruby_version)
29
+ options = [].tap do |o|
30
+ o << '--git' if opts.fetch(:git, false)
31
+ o << '--tiny' if opts.fetch(:tiny, false)
32
+ o << '--api-only' if opts.fetch(:api_only, false)
33
+ o << "--test_framework=#{opts[:test_framework]}" if opts.key?(:test_framework)
34
+ o << "--type=#{opts[:type]}" if opts.key?(:type)
35
+ o << "--ruby-version=#{opts[:ruby_version]}" if opts.key?(:ruby_version)
23
36
  end
24
37
 
25
38
  $hoboken_counter += 1
26
- bin_path = File.expand_path("../../bin/hoboken", __FILE__)
39
+ bin_path = File.expand_path('../bin/hoboken', __dir__)
27
40
 
28
- `#{bin_path} #{command} #{DESTINATION}/#{$hoboken_counter}/sample #{options.join(" ")}`
41
+ # rubocop:disable Layout/LineLength
42
+ `#{bin_path} #{command} #{DESTINATION}/#{$hoboken_counter}/sample #{options.join(' ')}`
43
+ # rubocop:enable Layout/LineLength
29
44
  yield
30
45
  end
46
+ # rubocop:enable Metrics/AbcSize
31
47
 
32
48
  def execute(command)
33
49
  FileUtils.cd("#{DESTINATION}/#{$hoboken_counter}/sample") do
34
- `bundle install` unless File.exists?("Gemfile.lock")
35
50
  `#{command}`
36
51
  end
37
52
  end
38
53
 
39
54
  def assert_file(filename, *contents)
40
- full_path = File.join(DESTINATION, $hoboken_counter.to_s, "sample", filename)
55
+ full_path = File.join(DESTINATION, $hoboken_counter.to_s, 'sample', filename)
56
+ assert_block("expected #{filename.inspect} to exist") do
57
+ File.exist?(full_path)
58
+ end
59
+
60
+ return if contents.empty?
61
+
62
+ read = File.read(full_path)
63
+ contents.each do |content|
64
+ assert_block("expected #{filename.inspect} to contain #{content}:\n#{read}") do
65
+ pattern = content.is_a?(Regexp) ? content : Regexp.new(Regexp.quote(content))
66
+ read =~ pattern
67
+ end
68
+ end
69
+ end
70
+
71
+ def assert_file_does_not_have_content(filename, *contents)
72
+ full_path = File.join(DESTINATION, $hoboken_counter.to_s, 'sample', filename)
41
73
  assert_block("expected #{filename.inspect} to exist") do
42
- File.exists?(full_path)
74
+ File.exist?(full_path)
43
75
  end
44
76
 
45
- unless contents.empty?
46
- read = File.read(full_path)
47
- contents.each do |content|
48
- assert_block("expected #{filename.inspect} to contain #{content}:\n#{read}") do
49
- pattern = content.is_a?(Regexp) ? content : Regexp.new(Regexp.quote(content))
50
- read =~ pattern
51
- end
77
+ read = File.read(full_path)
78
+ contents.each do |content|
79
+ assert_block("expected #{filename.inspect} to not contain #{content}:\n#{read}") do
80
+ pattern = content.is_a?(Regexp) ? content : Regexp.new(Regexp.quote(content))
81
+ read !~ pattern
52
82
  end
53
83
  end
54
84
  end
55
85
 
56
86
  def assert_directory(name)
57
87
  assert_block("expected #{name} directory to exist") do
58
- File.directory?(File.join(DESTINATION, $hoboken_counter.to_s, "sample", name))
88
+ File.directory?(File.join(DESTINATION, $hoboken_counter.to_s, 'sample', name))
59
89
  end
60
90
  end
61
91
 
62
92
  def refute_directory(name)
63
93
  assert_block("did not expect directory #{name} to exist") do
64
- !File.directory?(File.join(DESTINATION, $hoboken_counter.to_s, "sample", name))
94
+ !File.directory?(File.join(DESTINATION, $hoboken_counter.to_s, 'sample', name))
65
95
  end
66
96
  end
67
97
  end
98
+ # rubocop:enable Style/GlobalVars
@@ -1,8 +1,10 @@
1
- require_relative "../test_helper"
2
- require_relative "../../lib/hoboken/actions.rb"
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 "thor"
7
+ require 'thor'
6
8
  class Target < Thor::Group
7
9
  include Thor::Actions
8
10
  include Hoboken::Actions
@@ -12,100 +14,107 @@ module Hoboken
12
14
  attr_reader :gemfile_path, :gemfile, :target
13
15
 
14
16
  def setup
15
- @gemfile_path = File.join("test", "fixtures")
16
- @gemfile = File.join(gemfile_path, "Gemfile")
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, "Gemfile.pristine"), gemfile)
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 "sinatra", verbose: false
24
+ target.gem 'sinatra', verbose: false
23
25
  expected =
24
- "source \"https://rubygems.org\"\n" +
25
- "ruby \"2.0.0\"\n\n" +
26
- "gem \"sinatra\""
26
+ "source 'https://rubygems.org'\n" \
27
+ "ruby '2.0.0'\n\n" \
28
+ "gem 'sinatra'\n"
27
29
 
28
30
  assert_equal(expected, File.read(gemfile))
29
31
  end
30
32
 
31
33
  def test_gem_with_version
32
- target.gem "sinatra", version: "1.4.4", verbose: false
34
+ target.gem 'sinatra', version: '1.4.4', verbose: false
33
35
  expected =
34
- "source \"https://rubygems.org\"\n" +
35
- "ruby \"2.0.0\"\n\n" +
36
- "gem \"sinatra\", \"~> 1.4.4\""
36
+ "source 'https://rubygems.org'\n" \
37
+ "ruby '2.0.0'\n\n" \
38
+ "gem 'sinatra', '~> 1.4.4'\n"
37
39
 
38
40
  assert_equal(expected, File.read(gemfile))
39
41
  end
40
42
 
41
43
  def test_get_with_blank_version
42
- target.gem "sinatra", version: "", verbose: false
44
+ target.gem 'sinatra', version: '', verbose: false
43
45
  expected =
44
- "source \"https://rubygems.org\"\n" +
45
- "ruby \"2.0.0\"\n\n" +
46
- "gem \"sinatra\""
46
+ "source 'https://rubygems.org'\n" \
47
+ "ruby '2.0.0'\n\n" \
48
+ "gem 'sinatra'\n"
47
49
 
48
50
  assert_equal(expected, File.read(gemfile))
49
51
  end
50
52
 
51
53
  def test_gem_with_group
52
- target.gem "sinatra", version: "1.4.4", group: :test, verbose: false
54
+ target.gem 'sinatra', version: '1.4.4', group: :test, verbose: false
53
55
  expected =
54
- "source \"https://rubygems.org\"\n" +
55
- "ruby \"2.0.0\"\n\n" +
56
- "gem \"sinatra\", \"~> 1.4.4\", group: :test"
56
+ "source 'https://rubygems.org'\n" \
57
+ "ruby '2.0.0'\n\n" \
58
+ "gem 'sinatra', '~> 1.4.4', group: :test\n"
57
59
 
58
60
  assert_equal(expected, File.read(gemfile))
59
61
  end
60
62
 
61
63
  def test_gem_with_multiple_groups
62
- target.gem "sinatra", version: "1.4.4", group: [:test, :development], verbose: false
64
+ target.gem 'sinatra', version: '1.4.4', group: %i[test development], verbose: false
63
65
  expected =
64
- "source \"https://rubygems.org\"\n" +
65
- "ruby \"2.0.0\"\n\n" +
66
- "gem \"sinatra\", \"~> 1.4.4\", group: [:test, :development]"
66
+ "source 'https://rubygems.org'\n" \
67
+ "ruby '2.0.0'\n\n" \
68
+ "gem 'sinatra', '~> 1.4.4', group: [:test, :development]\n"
67
69
 
68
70
  assert_equal(expected, File.read(gemfile))
69
71
  end
70
72
 
71
73
  def test_gem_with_require
72
- target.gem "sinatra", version: "1.4.4", require: false, verbose: false
74
+ target.gem 'sinatra', version: '1.4.4', require: false, verbose: false
73
75
  expected =
74
- "source \"https://rubygems.org\"\n" +
75
- "ruby \"2.0.0\"\n\n" +
76
- "gem \"sinatra\", \"~> 1.4.4\", require: false"
76
+ "source 'https://rubygems.org'\n" \
77
+ "ruby '2.0.0'\n\n" \
78
+ "gem 'sinatra', '~> 1.4.4', require: false\n"
77
79
 
78
80
  assert_equal(expected, File.read(gemfile))
79
81
  end
80
82
 
81
83
  def test_gem_with_require_and_group
82
- target.gem "sinatra", version: "1.4.4", require: false, group: :test, verbose: false
84
+ target.gem 'sinatra', version: '1.4.4', require: false, group: :test, verbose: false
83
85
  expected =
84
- "source \"https://rubygems.org\"\n" +
85
- "ruby \"2.0.0\"\n\n" +
86
- "gem \"sinatra\", \"~> 1.4.4\", require: false, group: :test"
86
+ "source 'https://rubygems.org'\n" \
87
+ "ruby '2.0.0'\n\n" \
88
+ "gem 'sinatra', '~> 1.4.4', require: false, group: :test\n"
87
89
 
88
90
  assert_equal(expected, File.read(gemfile))
89
91
  end
90
92
 
91
93
  def test_gem_with_require_and_multiple_groups
92
- target.gem "sinatra", version: "1.4.4", require: false, group: [:test, :development], verbose: false
94
+ target.gem(
95
+ 'sinatra',
96
+ version: '1.4.4',
97
+ require: false,
98
+ group: %i[test development],
99
+ verbose: false
100
+ )
101
+
93
102
  expected =
94
- "source \"https://rubygems.org\"\n" +
95
- "ruby \"2.0.0\"\n\n" +
96
- "gem \"sinatra\", \"~> 1.4.4\", require: false, group: [:test, :development]"
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"
97
106
 
98
107
  assert_equal(expected, File.read(gemfile))
99
108
  end
100
109
 
101
110
  def test_gem_multiple
102
- target.gem "sinatra", version: "1.4.4", verbose: false
103
- target.gem "thin", version: "1.4.4", verbose: false
111
+ target.gem 'sinatra', version: '1.4.4', verbose: false
112
+ target.gem 'thin', version: '1.4.4', verbose: false
104
113
  expected =
105
- "source \"https://rubygems.org\"\n" +
106
- "ruby \"2.0.0\"\n\n" +
107
- "gem \"sinatra\", \"~> 1.4.4\"\n" +
108
- "gem \"thin\", \"~> 1.4.4\""
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"
109
118
 
110
119
  assert_equal(expected, File.read(gemfile))
111
120
  end
@@ -116,32 +125,32 @@ module Hoboken
116
125
 
117
126
  def setup
118
127
  @target = Target.new
119
- @text = <<-TEXT
128
+ @text = <<~TEXT
120
129
 
121
- This is some
122
- text that needs
123
- to be indented.
124
- TEXT
130
+ This is some
131
+ text that needs
132
+ to be indented.
133
+ TEXT
125
134
  end
126
135
 
127
136
  def test_indent_with_one_space
128
- expected = <<-TEXT
129
-
130
- This is some
131
- text that needs
132
- to be indented.
133
- TEXT
137
+ expected = <<~TEXT
138
+ #{' '}
139
+ This is some
140
+ text that needs
141
+ to be indented.
142
+ TEXT
134
143
 
135
144
  assert_equal(expected, target.indent(text, 1))
136
145
  end
137
146
 
138
147
  def test_indent_with_two_spaces
139
- expected = <<-TEXT
140
-
141
- This is some
142
- text that needs
143
- to be indented.
144
- TEXT
148
+ expected = <<~TEXT
149
+ #{' '}
150
+ This is some
151
+ text that needs
152
+ to be indented.
153
+ TEXT
145
154
 
146
155
  assert_equal(expected, target.indent(text, 2))
147
156
  end