appraisal 2.5.0 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/dynamic-security.yml +19 -0
  3. data/.github/workflows/main.yml +55 -0
  4. data/.gitignore +1 -0
  5. data/Gemfile +5 -0
  6. data/README.md +14 -5
  7. data/Rakefile +8 -6
  8. data/SECURITY.md +20 -0
  9. data/appraisal.gemspec +14 -17
  10. data/bin/bundle +109 -0
  11. data/bin/rspec +27 -0
  12. data/{bin → exe}/appraisal +6 -4
  13. data/lib/appraisal/appraisal.rb +20 -17
  14. data/lib/appraisal/appraisal_file.rb +8 -6
  15. data/lib/appraisal/bundler_dsl.rb +17 -13
  16. data/lib/appraisal/cli.rb +49 -43
  17. data/lib/appraisal/command.rb +3 -1
  18. data/lib/appraisal/conditional.rb +4 -0
  19. data/lib/appraisal/customize.rb +22 -2
  20. data/lib/appraisal/dependency.rb +4 -2
  21. data/lib/appraisal/dependency_list.rb +4 -2
  22. data/lib/appraisal/errors.rb +2 -0
  23. data/lib/appraisal/gemfile.rb +2 -0
  24. data/lib/appraisal/gemspec.rb +5 -3
  25. data/lib/appraisal/git.rb +3 -1
  26. data/lib/appraisal/group.rb +7 -5
  27. data/lib/appraisal/path.rb +3 -1
  28. data/lib/appraisal/platform.rb +7 -5
  29. data/lib/appraisal/source.rb +7 -5
  30. data/lib/appraisal/task.rb +8 -6
  31. data/lib/appraisal/utils.rb +6 -7
  32. data/lib/appraisal/version.rb +3 -1
  33. data/lib/appraisal.rb +4 -2
  34. data/spec/acceptance/appraisals_file_bundler_dsl_compatibility_spec.rb +55 -24
  35. data/spec/acceptance/bundle_with_custom_path_spec.rb +26 -20
  36. data/spec/acceptance/bundle_without_spec.rb +10 -10
  37. data/spec/acceptance/cli/clean_spec.rb +13 -11
  38. data/spec/acceptance/cli/generate_spec.rb +14 -12
  39. data/spec/acceptance/cli/help_spec.rb +15 -13
  40. data/spec/acceptance/cli/install_spec.rb +33 -47
  41. data/spec/acceptance/cli/list_spec.rb +11 -9
  42. data/spec/acceptance/cli/run_spec.rb +26 -24
  43. data/spec/acceptance/cli/update_spec.rb +20 -18
  44. data/spec/acceptance/cli/version_spec.rb +3 -1
  45. data/spec/acceptance/cli/with_no_arguments_spec.rb +10 -8
  46. data/spec/acceptance/gemfile_dsl_compatibility_spec.rb +38 -36
  47. data/spec/acceptance/gemspec_spec.rb +26 -24
  48. data/spec/appraisal/appraisal_file_spec.rb +66 -4
  49. data/spec/appraisal/appraisal_spec.rb +20 -23
  50. data/spec/appraisal/customize_spec.rb +133 -11
  51. data/spec/appraisal/dependency_list_spec.rb +3 -1
  52. data/spec/appraisal/gemfile_spec.rb +39 -38
  53. data/spec/appraisal/utils_spec.rb +21 -28
  54. data/spec/spec_helper.rb +14 -6
  55. data/spec/support/acceptance_test_helpers.rb +31 -24
  56. data/spec/support/dependency_helpers.rb +29 -15
  57. data/spec/support/stream_helpers.rb +2 -0
  58. metadata +10 -34
  59. data/.rspec +0 -1
@@ -1,27 +1,29 @@
1
- require 'spec_helper'
2
- require 'appraisal/gemfile'
3
- require 'active_support/core_ext/string/strip'
1
+ # frozen_string_literal: true
4
2
 
5
- describe Appraisal::Gemfile do
3
+ require "spec_helper"
4
+ require "appraisal/gemfile"
5
+ require "active_support/core_ext/string/strip"
6
+
7
+ RSpec.describe Appraisal::Gemfile do
6
8
  include StreamHelpers
7
9
 
8
10
  it "supports gemfiles without sources" do
9
11
  gemfile = Appraisal::Gemfile.new
10
- expect(gemfile.to_s.strip).to eq ''
12
+ expect(gemfile.to_s.strip).to eq ""
11
13
  end
12
14
 
13
15
  it "supports multiple sources" do
14
16
  gemfile = Appraisal::Gemfile.new
15
17
  gemfile.source "one"
16
18
  gemfile.source "two"
17
- expect(gemfile.to_s.strip).to eq %{source "one"\nsource "two"}
19
+ expect(gemfile.to_s.strip).to eq %(source "one"\nsource "two")
18
20
  end
19
21
 
20
22
  it "ignores duplicate sources" do
21
23
  gemfile = Appraisal::Gemfile.new
22
24
  gemfile.source "one"
23
25
  gemfile.source "one"
24
- expect(gemfile.to_s.strip).to eq %{source "one"}
26
+ expect(gemfile.to_s.strip).to eq %(source "one")
25
27
  end
26
28
 
27
29
  it "preserves dependency order" do
@@ -35,10 +37,10 @@ describe Appraisal::Gemfile do
35
37
  it "supports symbol sources" do
36
38
  gemfile = Appraisal::Gemfile.new
37
39
  gemfile.source :one
38
- expect(gemfile.to_s.strip).to eq %{source :one}
40
+ expect(gemfile.to_s.strip).to eq %(source :one)
39
41
  end
40
42
 
41
- it 'supports group syntax' do
43
+ it "supports group syntax" do
42
44
  gemfile = Appraisal::Gemfile.new
43
45
 
44
46
  gemfile.group :development, :test do
@@ -84,7 +86,7 @@ describe Appraisal::Gemfile do
84
86
  GEMFILE
85
87
  end
86
88
 
87
- it 'supports platform syntax' do
89
+ it "supports platform syntax" do
88
90
  gemfile = Appraisal::Gemfile.new
89
91
 
90
92
  gemfile.platform :jruby do
@@ -226,7 +228,7 @@ describe Appraisal::Gemfile do
226
228
  context "no contents" do
227
229
  it "shows empty string" do
228
230
  gemfile = Appraisal::Gemfile.new
229
- expect(gemfile.to_s).to eq ''
231
+ expect(gemfile.to_s).to eq ""
230
232
  end
231
233
  end
232
234
 
@@ -251,26 +253,26 @@ describe Appraisal::Gemfile do
251
253
  end
252
254
 
253
255
  context "relative path handling" do
254
- before { stub_const('RUBY_VERSION', '2.3.0') }
256
+ before { stub_const("RUBY_VERSION", "2.3.0") }
255
257
 
256
258
  context "in :path option" do
257
259
  it "handles dot path" do
258
260
  gemfile = Appraisal::Gemfile.new
259
- gemfile.gem "bacon", :path => "."
261
+ gemfile.gem "bacon", path: "."
260
262
 
261
263
  expect(gemfile.to_s).to eq %(gem "bacon", path: "../")
262
264
  end
263
265
 
264
266
  it "handles relative path" do
265
267
  gemfile = Appraisal::Gemfile.new
266
- gemfile.gem "bacon", :path => "../bacon"
268
+ gemfile.gem "bacon", path: "../bacon"
267
269
 
268
270
  expect(gemfile.to_s).to eq %(gem "bacon", path: "../../bacon")
269
271
  end
270
272
 
271
273
  it "handles absolute path" do
272
274
  gemfile = Appraisal::Gemfile.new
273
- gemfile.gem "bacon", :path => "/tmp"
275
+ gemfile.gem "bacon", path: "/tmp"
274
276
 
275
277
  expect(gemfile.to_s).to eq %(gem "bacon", path: "/tmp")
276
278
  end
@@ -279,31 +281,30 @@ describe Appraisal::Gemfile do
279
281
  context "in :git option" do
280
282
  it "handles dot git path" do
281
283
  gemfile = Appraisal::Gemfile.new
282
- gemfile.gem "bacon", :git => "."
284
+ gemfile.gem "bacon", git: "."
283
285
 
284
286
  expect(gemfile.to_s).to eq %(gem "bacon", git: "../")
285
287
  end
286
288
 
287
289
  it "handles relative git path" do
288
290
  gemfile = Appraisal::Gemfile.new
289
- gemfile.gem "bacon", :git => "../bacon"
291
+ gemfile.gem "bacon", git: "../bacon"
290
292
 
291
293
  expect(gemfile.to_s).to eq %(gem "bacon", git: "../../bacon")
292
294
  end
293
295
 
294
296
  it "handles absolute git path" do
295
297
  gemfile = Appraisal::Gemfile.new
296
- gemfile.gem "bacon", :git => "/tmp"
298
+ gemfile.gem "bacon", git: "/tmp"
297
299
 
298
300
  expect(gemfile.to_s).to eq %(gem "bacon", git: "/tmp")
299
301
  end
300
302
 
301
303
  it "handles git uri" do
302
304
  gemfile = Appraisal::Gemfile.new
303
- gemfile.gem "bacon", :git => "git@github.com:bacon/bacon.git"
305
+ gemfile.gem "bacon", git: "git@github.com:bacon/bacon.git"
304
306
 
305
- expect(gemfile.to_s).
306
- to eq %(gem "bacon", git: "git@github.com:bacon/bacon.git")
307
+ expect(gemfile.to_s).to eq %(gem "bacon", git: "git@github.com:bacon/bacon.git")
307
308
  end
308
309
  end
309
310
 
@@ -315,11 +316,11 @@ describe Appraisal::Gemfile do
315
316
  gem "bacon"
316
317
  end
317
318
 
318
- expect(gemfile.to_s).to eq <<-gemfile.strip_heredoc.strip
319
+ expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
319
320
  path "../" do
320
321
  gem "bacon"
321
322
  end
322
- gemfile
323
+ GEMFILE
323
324
  end
324
325
 
325
326
  it "handles relative path" do
@@ -329,11 +330,11 @@ describe Appraisal::Gemfile do
329
330
  gem "bacon"
330
331
  end
331
332
 
332
- expect(gemfile.to_s).to eq <<-gemfile.strip_heredoc.strip
333
+ expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
333
334
  path "../../bacon" do
334
335
  gem "bacon"
335
336
  end
336
- gemfile
337
+ GEMFILE
337
338
  end
338
339
 
339
340
  it "handles absolute path" do
@@ -343,11 +344,11 @@ describe Appraisal::Gemfile do
343
344
  gem "bacon"
344
345
  end
345
346
 
346
- expect(gemfile.to_s).to eq <<-gemfile.strip_heredoc.strip
347
+ expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
347
348
  path "/tmp" do
348
349
  gem "bacon"
349
350
  end
350
- gemfile
351
+ GEMFILE
351
352
  end
352
353
  end
353
354
 
@@ -359,11 +360,11 @@ describe Appraisal::Gemfile do
359
360
  gem "bacon"
360
361
  end
361
362
 
362
- expect(gemfile.to_s).to eq <<-gemfile.strip_heredoc.strip
363
+ expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
363
364
  git "../" do
364
365
  gem "bacon"
365
366
  end
366
- gemfile
367
+ GEMFILE
367
368
  end
368
369
 
369
370
  it "handles relative git path" do
@@ -373,11 +374,11 @@ describe Appraisal::Gemfile do
373
374
  gem "bacon"
374
375
  end
375
376
 
376
- expect(gemfile.to_s).to eq <<-gemfile.strip_heredoc.strip
377
+ expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
377
378
  git "../../bacon" do
378
379
  gem "bacon"
379
380
  end
380
- gemfile
381
+ GEMFILE
381
382
  end
382
383
 
383
384
  it "handles absolute git path" do
@@ -387,11 +388,11 @@ describe Appraisal::Gemfile do
387
388
  gem "bacon"
388
389
  end
389
390
 
390
- expect(gemfile.to_s).to eq <<-gemfile.strip_heredoc.strip
391
+ expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
391
392
  git "/tmp" do
392
393
  gem "bacon"
393
394
  end
394
- gemfile
395
+ GEMFILE
395
396
  end
396
397
 
397
398
  it "handles git uri" do
@@ -401,18 +402,18 @@ describe Appraisal::Gemfile do
401
402
  gem "bacon"
402
403
  end
403
404
 
404
- expect(gemfile.to_s).to eq <<-gemfile.strip_heredoc.strip
405
+ expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
405
406
  git "git@github.com:bacon/bacon.git" do
406
407
  gem "bacon"
407
408
  end
408
- gemfile
409
+ GEMFILE
409
410
  end
410
411
  end
411
412
 
412
413
  context "in gemspec directive" do
413
414
  it "handles gemspec path" do
414
415
  gemfile = Appraisal::Gemfile.new
415
- gemfile.gemspec :path => "."
416
+ gemfile.gemspec path: "."
416
417
 
417
418
  expect(gemfile.to_s).to eq %(gemspec path: "../")
418
419
  end
@@ -420,12 +421,12 @@ describe Appraisal::Gemfile do
420
421
  end
421
422
 
422
423
  context "git_source support" do
423
- before { stub_const('RUBY_VERSION', '2.3.0') }
424
+ before { stub_const("RUBY_VERSION", "2.3.0") }
424
425
 
425
426
  it "stores git_source declaration and apply it as git option" do
426
427
  gemfile = Appraisal::Gemfile.new
427
428
  gemfile.git_source(:custom_source) { |repo| "path/#{repo}" }
428
- gemfile.gem "bacon", :custom_source => "bacon_pancake"
429
+ gemfile.gem "bacon", custom_source: "bacon_pancake"
429
430
 
430
431
  expect(gemfile.to_s).to eq %(gem "bacon", git: "../path/bacon_pancake")
431
432
  end
@@ -1,34 +1,32 @@
1
- require 'spec_helper'
2
- require 'appraisal/utils'
1
+ # frozen_string_literal: true
3
2
 
4
- describe Appraisal::Utils do
5
- describe '.format_string' do
3
+ require "spec_helper"
4
+ require "appraisal/utils"
5
+
6
+ RSpec.describe Appraisal::Utils do
7
+ describe ".format_string" do
6
8
  it "prints out a nice looking hash without brackets with new syntax" do
7
- hash = { :foo => 'bar' }
9
+ hash = { foo: "bar" }
8
10
  expect(Appraisal::Utils.format_string(hash)).to eq('foo: "bar"')
9
11
 
10
- hash = { 'baz' => { :ball => 'boo' }}
11
- expect(Appraisal::Utils.format_string(hash)).
12
- to eq('"baz" => { ball: "boo" }')
12
+ hash = { "baz" => { ball: "boo" } }
13
+ expect(Appraisal::Utils.format_string(hash)).to eq('"baz" => { ball: "boo" }')
13
14
  end
14
15
  end
15
16
 
16
- describe '.format_arguments' do
17
- before { stub_const('RUBY_VERSION', '2.3.0') }
17
+ describe ".format_arguments" do
18
+ before { stub_const("RUBY_VERSION", "2.3.0") }
18
19
 
19
- it 'prints out arguments without enclosing square brackets' do
20
- arguments = [:foo, { :bar => { :baz => 'ball' }}]
20
+ it "prints out arguments without enclosing square brackets" do
21
+ arguments = [:foo, { bar: { baz: "ball" } }]
21
22
 
22
- expect(Appraisal::Utils.format_arguments(arguments)).to eq(
23
- ':foo, bar: { baz: "ball" }'
24
- )
23
+ expect(Appraisal::Utils.format_arguments(arguments)).to eq(':foo, bar: { baz: "ball" }')
25
24
  end
26
25
 
27
26
  it "returns nil if arguments is empty" do
28
27
  arguments = []
29
28
 
30
- expect(Appraisal::Utils.format_arguments(arguments)).
31
- to eq(nil)
29
+ expect(Appraisal::Utils.format_arguments(arguments)).to eq(nil)
32
30
  end
33
31
  end
34
32
 
@@ -45,25 +43,20 @@ describe Appraisal::Utils do
45
43
  expect(Appraisal::Utils.prefix_path("/tmp")).to eq "/tmp"
46
44
  end
47
45
 
48
- it "strips out './' from path" do
49
- expect(Appraisal::Utils.prefix_path("./tmp/./appraisal././")).
50
- to eq "../tmp/appraisal./"
46
+ it "strips out './' from path" do
47
+ expect(Appraisal::Utils.prefix_path("./tmp/./appraisal././")).to eq "../tmp/appraisal./"
51
48
  end
52
49
 
53
50
  it "does not prefix Git uri" do
54
- expect(Appraisal::Utils.prefix_path("git@github.com:bacon/bacon.git")).
55
- to eq "git@github.com:bacon/bacon.git"
56
- expect(Appraisal::Utils.prefix_path("git://github.com/bacon/bacon.git")).
57
- to eq "git://github.com/bacon/bacon.git"
58
- expect(
59
- Appraisal::Utils.prefix_path("https://github.com/bacon/bacon.git")
60
- ).to eq("https://github.com/bacon/bacon.git")
51
+ expect(Appraisal::Utils.prefix_path("git@github.com:bacon/bacon.git")).to eq "git@github.com:bacon/bacon.git"
52
+ expect(Appraisal::Utils.prefix_path("git://github.com/bacon/bacon.git")).to eq "git://github.com/bacon/bacon.git"
53
+ expect(Appraisal::Utils.prefix_path("https://github.com/bacon/bacon.git")).to eq("https://github.com/bacon/bacon.git")
61
54
  end
62
55
  end
63
56
 
64
57
  describe ".bundler_version" do
65
58
  it "returns the bundler version" do
66
- bundler = double("Bundler", :name => "bundler", :version => "a.b.c")
59
+ bundler = double("Bundler", name: "bundler", version: "a.b.c")
67
60
  allow(Gem::Specification).to receive(:detect).and_return(bundler)
68
61
 
69
62
  version = Appraisal::Utils.bundler_version
data/spec/spec_helper.rb CHANGED
@@ -1,22 +1,30 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+ require "bundler/setup"
3
5
  require "./spec/support/acceptance_test_helpers"
4
6
  require "./spec/support/stream_helpers"
5
7
 
6
- PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
7
- TMP_GEM_ROOT = File.join(PROJECT_ROOT, "tmp", "gems")
8
+ PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..")).freeze
9
+ TMP_GEM_ROOT = File.join(PROJECT_ROOT, "tmp", "bundler")
10
+ TMP_GEM_BUILD = File.join(PROJECT_ROOT, "tmp", "build")
8
11
  ENV["APPRAISAL_UNDER_TEST"] = "1"
9
12
 
10
13
  RSpec.configure do |config|
11
14
  config.raise_errors_for_deprecations!
12
15
 
13
- config.define_derived_metadata(:file_path => %r{spec\/acceptance\/}) do |metadata|
16
+ config.define_derived_metadata(file_path: %r{spec\/acceptance\/}) do |metadata|
14
17
  metadata[:type] = :acceptance
15
18
  end
16
19
 
17
- config.include AcceptanceTestHelpers, :type => :acceptance
20
+ config.include AcceptanceTestHelpers, type: :acceptance
21
+
22
+ # disable monkey patching
23
+ # see: https://relishapp.com/rspec/rspec-core/v/3-8/docs/configuration/zero-monkey-patching-mode
24
+ config.disable_monkey_patching!
18
25
 
19
26
  config.before :suite do
20
27
  FileUtils.rm_rf TMP_GEM_ROOT
28
+ FileUtils.rm_rf TMP_GEM_BUILD
21
29
  end
22
30
  end
@@ -1,23 +1,30 @@
1
- require 'rspec/expectations/expectation_target'
2
- require 'active_support/core_ext/string/strip'
3
- require 'active_support/core_ext/string/filters'
4
- require 'active_support/concern'
5
- require 'appraisal/utils'
1
+ # frozen_string_literal: true
2
+
3
+ require "rspec/expectations/expectation_target"
4
+ require "active_support/core_ext/string/strip"
5
+ require "active_support/core_ext/string/filters"
6
+ require "active_support/concern"
7
+ require "appraisal/utils"
6
8
  require "./spec/support/dependency_helpers"
7
9
 
8
10
  module AcceptanceTestHelpers
9
11
  extend ActiveSupport::Concern
10
12
  include DependencyHelpers
11
13
 
12
- BUNDLER_ENVIRONMENT_VARIABLES = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH
13
- BUNDLE_GEMFILE)
14
+ BUNDLER_ENVIRONMENT_VARIABLES = %w[
15
+ RUBYOPT
16
+ BUNDLE_PATH
17
+ BUNDLE_BIN_PATH
18
+ BUNDLE_GEMFILE
19
+ BUNDLER_SETUP
20
+ ].freeze
14
21
 
15
22
  included do
16
23
  metadata[:type] = :acceptance
17
24
 
18
- before :parallel => true do
25
+ before parallel: true do
19
26
  unless Appraisal::Utils.support_parallel_installation?
20
- pending 'This Bundler version does not support --jobs flag.'
27
+ pending "This Bundler version does not support --jobs flag."
21
28
  end
22
29
  end
23
30
 
@@ -39,7 +46,7 @@ module AcceptanceTestHelpers
39
46
  def save_environment_variables
40
47
  @original_environment_variables = {}
41
48
 
42
- (BUNDLER_ENVIRONMENT_VARIABLES + %w(PATH)).each do |key|
49
+ (BUNDLER_ENVIRONMENT_VARIABLES + %w[PATH]).each do |key|
43
50
  @original_environment_variables[key] = ENV[key]
44
51
  end
45
52
  end
@@ -51,7 +58,7 @@ module AcceptanceTestHelpers
51
58
  end
52
59
 
53
60
  def add_binstub_path
54
- ENV['PATH'] = "bin:#{ENV['PATH']}"
61
+ ENV["PATH"] = "bin:#{ENV['PATH']}"
55
62
  end
56
63
 
57
64
  def restore_environment_variables
@@ -61,28 +68,28 @@ module AcceptanceTestHelpers
61
68
  end
62
69
 
63
70
  def build_appraisal_file(content)
64
- write_file 'Appraisals', content.strip_heredoc
71
+ write_file "Appraisals", content.strip_heredoc
65
72
  end
66
73
 
67
74
  def build_gemfile(content)
68
- write_file 'Gemfile', content.strip_heredoc
75
+ write_file "Gemfile", content.strip_heredoc
69
76
  end
70
77
 
71
78
  def add_gemspec_to_gemfile
72
79
  in_test_directory do
73
- File.open('Gemfile', 'a') { |file| file.puts 'gemspec' }
80
+ File.open("Gemfile", "a") { |file| file.puts "gemspec" }
74
81
  end
75
82
  end
76
83
 
77
84
  def build_gemspec
78
- write_file "stage.gemspec", <<-gemspec
85
+ write_file "stage.gemspec", <<-GEMSPEC
79
86
  Gem::Specification.new do |s|
80
87
  s.name = 'stage'
81
88
  s.version = '0.1'
82
89
  s.summary = 'Awesome Gem!'
83
90
  s.authors = "Appraisal"
84
91
  end
85
- gemspec
92
+ GEMSPEC
86
93
  end
87
94
 
88
95
  def content_of(path)
@@ -102,11 +109,11 @@ module AcceptanceTestHelpers
102
109
  private
103
110
 
104
111
  def current_directory
105
- File.expand_path('tmp/stage')
112
+ File.expand_path("tmp/stage")
106
113
  end
107
114
 
108
115
  def write_file(filename, content)
109
- in_test_directory { File.open(filename, 'w') { |file| file.puts content } }
116
+ in_test_directory { File.open(filename, "w") { |file| file.puts content } }
110
117
  end
111
118
 
112
119
  def cleanup_artifacts
@@ -116,8 +123,8 @@ module AcceptanceTestHelpers
116
123
  def build_default_dummy_gems
117
124
  FileUtils.mkdir_p(TMP_GEM_ROOT)
118
125
 
119
- build_gem 'dummy', '1.0.0'
120
- build_gem 'dummy', '1.1.0'
126
+ build_gem "dummy", "1.0.0"
127
+ build_gem "dummy", "1.1.0"
121
128
  end
122
129
 
123
130
  def ensure_bundler_is_available
@@ -135,11 +142,11 @@ module AcceptanceTestHelpers
135
142
  end
136
143
 
137
144
  def build_default_gemfile
138
- build_gemfile <<-Gemfile
145
+ build_gemfile <<-GEMFILE
139
146
  source 'https://rubygems.org'
140
147
 
141
148
  gem 'appraisal', :path => '#{PROJECT_ROOT}'
142
- Gemfile
149
+ GEMFILE
143
150
 
144
151
  run "bundle install --local"
145
152
  run "bundle binstubs --all"
@@ -160,10 +167,10 @@ module AcceptanceTestHelpers
160
167
  end
161
168
 
162
169
  if raise_on_error && exitstatus != 0
163
- raise RuntimeError, <<-error_message.strip_heredoc
170
+ raise RuntimeError, <<-ERROR_MESSAGE.strip_heredoc
164
171
  Command #{command.inspect} exited with status #{exitstatus}. Output:
165
172
  #{output.gsub(/^/, ' ')}
166
- error_message
173
+ ERROR_MESSAGE
167
174
  end
168
175
  end
169
176
  end
@@ -1,32 +1,44 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DependencyHelpers
2
- def build_gem(gem_name, version = '1.0.0')
3
- ENV['GEM_HOME'] = TMP_GEM_ROOT
4
+ def build_gem(gem_name, version = "1.0.0")
5
+ ENV["GEM_HOME"] = TMP_GEM_ROOT
4
6
 
5
- unless File.exist? "tmp/gems/gems/#{gem_name}-#{version}"
6
- FileUtils.mkdir_p "tmp/gems/#{gem_name}/lib"
7
+ unless File.exist? "#{TMP_GEM_ROOT}/gems/#{gem_name}-#{version}"
8
+ FileUtils.mkdir_p "#{TMP_GEM_BUILD}/#{gem_name}/lib"
7
9
 
8
- FileUtils.cd "tmp/gems/#{gem_name}" do
10
+ FileUtils.cd "#{TMP_GEM_BUILD}/#{gem_name}" do
9
11
  gemspec = "#{gem_name}.gemspec"
10
12
  lib_file = "lib/#{gem_name}.rb"
11
13
 
12
- File.open gemspec, 'w' do |file|
13
- file.puts <<-gemspec
14
+ File.open gemspec, "w" do |file|
15
+ file.puts <<-GEMSPEC
14
16
  Gem::Specification.new do |s|
15
17
  s.name = #{gem_name.inspect}
16
18
  s.version = #{version.inspect}
17
19
  s.authors = 'Mr. Smith'
18
20
  s.summary = 'summary'
19
21
  s.files = #{lib_file.inspect}
22
+ s.license = 'MIT'
23
+ s.homepage = 'http://github.com/thoughtbot/#{gem_name}'
24
+ s.required_ruby_version = '>= 2.3.0'
20
25
  end
21
- gemspec
26
+ GEMSPEC
22
27
  end
23
28
 
24
- File.open lib_file, 'w' do |file|
29
+ File.open lib_file, "w" do |file|
25
30
  file.puts "$#{gem_name}_version = '#{version}'"
26
31
  end
27
32
 
28
- `gem build #{gemspec} 2>&1`
29
- `gem install -lN #{gem_name}-#{version}.gem -v #{version} 2>&1`
33
+ redirect = ENV["VERBOSE"] ? "" : "2>&1"
34
+
35
+ puts "building gem: #{gem_name} #{version}" if ENV["VERBOSE"]
36
+ `gem build #{gemspec} #{redirect}`
37
+
38
+ puts "installing gem: #{gem_name} #{version}" if ENV["VERBOSE"]
39
+ `gem install -lN #{gem_name}-#{version}.gem -v #{version} #{redirect}`
40
+
41
+ puts "" if ENV["VERBOSE"]
30
42
  end
31
43
  end
32
44
  end
@@ -35,21 +47,23 @@ module DependencyHelpers
35
47
  gems.each { |gem| build_gem(gem) }
36
48
  end
37
49
 
38
- def build_git_gem(gem_name, version = '1.0.0')
50
+ def build_git_gem(gem_name, version = "1.0.0")
51
+ puts "building git gem: #{gem_name} #{version}" if ENV["VERBOSE"]
39
52
  build_gem gem_name, version
40
53
 
41
- Dir.chdir "tmp/gems/#{gem_name}" do
42
- `git init .`
54
+ Dir.chdir "#{TMP_GEM_BUILD}/#{gem_name}" do
55
+ `git init . --initial-branch=master`
43
56
  `git config user.email "appraisal@thoughtbot.com"`
44
57
  `git config user.name "Appraisal"`
45
58
  `git add .`
46
- `git commit -a -m "initial commit"`
59
+ `git commit --all --no-verify --message "initial commit"`
47
60
  end
48
61
 
49
62
  # Cleanup Bundler cache path manually for now
50
63
  git_cache_path = File.join(ENV["GEM_HOME"], "cache", "bundler", "git")
51
64
 
52
65
  Dir[File.join(git_cache_path, "#{gem_name}-*")].each do |path|
66
+ puts "deleting: #{path}" if ENV["VERBOSE"]
53
67
  FileUtils.rm_r(path)
54
68
  end
55
69
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "tempfile"
2
4
 
3
5
  module StreamHelpers