ggem 1.9.5 → 1.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ggem.gemspec +9 -7
- data/lib/ggem/cli.rb +17 -15
- data/lib/ggem/cli/commands.rb +51 -45
- data/lib/ggem/gem.rb +7 -6
- data/lib/ggem/gemspec.rb +20 -10
- data/lib/ggem/git_repo.rb +2 -1
- data/lib/ggem/template.rb +12 -8
- data/lib/ggem/template_file/gemspec.erb +5 -3
- data/lib/ggem/template_file/gitignore.erb +1 -0
- data/lib/ggem/template_file/l.yml.erb +8 -0
- data/lib/ggem/template_file/rubocop.yml.erb +3 -0
- data/lib/ggem/template_file/ruby-version.erb +1 -1
- data/lib/ggem/template_file/t.yml.erb +6 -0
- data/lib/ggem/version.rb +1 -1
- data/test/support/cmd_tests_helpers.rb +7 -7
- data/test/support/gem1/gem1.gemspec +3 -4
- data/test/support/gem2/gem2.gemspec +3 -4
- data/test/support/name_set.rb +6 -3
- data/test/system/ggem_tests.rb +7 -6
- data/test/unit/cli_tests.rb +84 -59
- data/test/unit/gemspec_tests.rb +11 -6
- data/test/unit/git_repo_tests.rb +9 -7
- metadata +27 -10
data/lib/ggem/git_repo.rb
CHANGED
@@ -4,6 +4,7 @@ require "pathname"
|
|
4
4
|
require "scmd"
|
5
5
|
|
6
6
|
module GGem; end
|
7
|
+
|
7
8
|
class GGem::GitRepo
|
8
9
|
NotFoundError = Class.new(ArgumentError)
|
9
10
|
CmdError = Class.new(RuntimeError)
|
@@ -48,7 +49,7 @@ class GGem::GitRepo
|
|
48
49
|
cmd_string = "cd #{@path} && #{cmd_string}"
|
49
50
|
cmd = Scmd.new(cmd_string)
|
50
51
|
cmd.run
|
51
|
-
|
52
|
+
unless cmd.success?
|
52
53
|
raise CmdError, "#{cmd_string}\n" \
|
53
54
|
"#{cmd.stderr.empty? ? cmd.stdout : cmd.stderr}"
|
54
55
|
end
|
data/lib/ggem/template.rb
CHANGED
@@ -4,6 +4,7 @@ require "erb"
|
|
4
4
|
require "fileutils"
|
5
5
|
|
6
6
|
module GGem; end
|
7
|
+
|
7
8
|
class GGem::Template
|
8
9
|
def initialize(ggem)
|
9
10
|
@ggem = ggem
|
@@ -18,12 +19,15 @@ class GGem::Template
|
|
18
19
|
save_folder "log"
|
19
20
|
save_folder "tmp"
|
20
21
|
|
22
|
+
save_file("l.yml.erb", ".l.yml")
|
23
|
+
save_file("t.yml.erb", ".t.yml")
|
24
|
+
save_file("rubocop.yml.erb", ".rubocop.yml")
|
21
25
|
save_file("ruby-version.erb", ".ruby-version")
|
22
|
-
save_file("gitignore.erb",
|
23
|
-
save_file("Gemfile.erb",
|
24
|
-
save_file("gemspec.erb",
|
25
|
-
save_file("README.md.erb",
|
26
|
-
save_file("LICENSE.erb",
|
26
|
+
save_file("gitignore.erb", ".gitignore")
|
27
|
+
save_file("Gemfile.erb", "Gemfile")
|
28
|
+
save_file("gemspec.erb", "#{@ggem.name}.gemspec")
|
29
|
+
save_file("README.md.erb", "README.md")
|
30
|
+
save_file("LICENSE.erb", "LICENSE")
|
27
31
|
|
28
32
|
save_file("lib.rb.erb", "lib/#{@ggem.ruby_name}.rb")
|
29
33
|
save_file("lib_version.rb.erb", "lib/#{@ggem.ruby_name}/version.rb")
|
@@ -39,7 +43,7 @@ class GGem::Template
|
|
39
43
|
|
40
44
|
private
|
41
45
|
|
42
|
-
def save_folder(relative_path=nil)
|
46
|
+
def save_folder(relative_path = nil)
|
43
47
|
path = File.join([@ggem.path, relative_path].compact)
|
44
48
|
FileUtils.mkdir_p(path)
|
45
49
|
end
|
@@ -53,10 +57,10 @@ class GGem::Template
|
|
53
57
|
source_file = File.join(File.dirname(__FILE__), "template_file", source)
|
54
58
|
output_file = File.join(@ggem.root_path, @ggem.name, output)
|
55
59
|
|
56
|
-
if File.
|
60
|
+
if File.exist?(source_file)
|
57
61
|
FileUtils.mkdir_p(File.dirname(output_file))
|
58
62
|
erb = ERB.new(File.read(source_file))
|
59
|
-
File.open(output_file, "w")
|
63
|
+
File.open(output_file, "w"){ |f| f << erb.result(binding) }
|
60
64
|
else
|
61
65
|
raise ArgumentError, "the source file `#{source_file}` does not exist"
|
62
66
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
|
-
# -*- encoding: utf-8 -*-
|
4
4
|
lib = File.expand_path("../lib", __FILE__)
|
5
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
6
|
require "<%= @ggem.ruby_name %>/version"
|
@@ -15,14 +15,16 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.homepage = "TODO: homepage"
|
16
16
|
gem.license = "MIT"
|
17
17
|
|
18
|
-
gem.files
|
18
|
+
gem.files = `git ls-files | grep "^[^.]"`.split($INPUT_RECORD_SEPARATOR)
|
19
|
+
|
19
20
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
21
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
22
|
gem.require_paths = ["lib"]
|
22
23
|
|
23
24
|
gem.required_ruby_version = "~> 2.5"
|
24
25
|
|
25
|
-
gem.add_development_dependency("
|
26
|
+
gem.add_development_dependency("much-style-guide", ["~> 0.6.4"])
|
27
|
+
gem.add_development_dependency("assert", ["~> 2.19.6"])
|
26
28
|
|
27
29
|
# TODO: gem.add_dependency("gem-name", ["~> 0.0.0"])
|
28
30
|
end
|
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.8
|
data/lib/ggem/version.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "much-
|
3
|
+
require "much-mixin"
|
4
4
|
require "scmd"
|
5
5
|
|
6
6
|
module GGem; end
|
7
|
+
|
7
8
|
module GGem::CmdTestsHelpers
|
8
|
-
include
|
9
|
+
include MuchMixin
|
9
10
|
|
10
|
-
|
11
|
+
mixin_included do
|
11
12
|
setup do
|
12
13
|
ENV["SCMD_TEST_MODE"] = "1"
|
13
14
|
|
@@ -39,12 +40,11 @@ module GGem::CmdTestsHelpers
|
|
39
40
|
cmd.stderr = Factory.string
|
40
41
|
@cmd_spy = cmd
|
41
42
|
end
|
42
|
-
err = nil
|
43
|
-
begin; run_cmd_block.call; rescue StandardError => err; end
|
44
43
|
|
45
|
-
|
44
|
+
ex =
|
45
|
+
assert_that{ run_cmd_block.call }.raises(cmd_error_class)
|
46
46
|
exp = "#{@cmd_spy.cmd_str}\n#{@cmd_spy.stderr}"
|
47
|
-
assert_equal exp,
|
47
|
+
assert_equal exp, ex.message
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -1,18 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
|
-
# -*- encoding: utf-8 -*-
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "gem1"
|
6
6
|
gem.version = "0.1.0"
|
7
7
|
gem.authors = []
|
8
8
|
gem.email = []
|
9
|
-
gem.summary =
|
10
|
-
gem.description =
|
9
|
+
gem.summary = "Gem 1 summary"
|
10
|
+
gem.description = "Gem 1 description"
|
11
11
|
gem.license = "MIT"
|
12
12
|
|
13
13
|
gem.files = []
|
14
14
|
gem.executables = []
|
15
15
|
gem.test_files = []
|
16
16
|
gem.require_paths = []
|
17
|
-
|
18
17
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
|
-
# -*- encoding: utf-8 -*-
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "gem2"
|
6
6
|
gem.version = "0.2.0"
|
7
7
|
gem.authors = []
|
8
8
|
gem.email = []
|
9
|
-
gem.summary =
|
10
|
-
gem.description =
|
9
|
+
gem.summary = "Gem 2 summary"
|
10
|
+
gem.description = "Gem 2 description"
|
11
11
|
gem.license = "MIT"
|
12
12
|
|
13
13
|
gem.metadata["allowed_push_host"] = "http://gems.example.com"
|
@@ -16,5 +16,4 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.executables = []
|
17
17
|
gem.test_files = []
|
18
18
|
gem.require_paths = []
|
19
|
-
|
20
19
|
end
|
data/test/support/name_set.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module GGem; end
|
4
|
+
|
4
5
|
module GGem::NameSet
|
5
6
|
class Base
|
6
7
|
attr_reader :variations, :name, :module_name, :ruby_name
|
7
8
|
|
8
9
|
def expected_folders
|
9
|
-
[
|
10
|
+
[
|
11
|
+
"",
|
10
12
|
"lib",
|
11
13
|
"lib/#{@ruby_name}",
|
12
14
|
"test",
|
@@ -14,12 +16,13 @@ module GGem::NameSet
|
|
14
16
|
"test/system",
|
15
17
|
"test/unit",
|
16
18
|
"log",
|
17
|
-
"tmp"
|
19
|
+
"tmp",
|
18
20
|
]
|
19
21
|
end
|
20
22
|
|
21
23
|
def expected_files
|
22
|
-
[
|
24
|
+
[
|
25
|
+
".ruby-version",
|
23
26
|
".gitignore",
|
24
27
|
"Gemfile",
|
25
28
|
"#{@name}.gemspec",
|
data/test/system/ggem_tests.rb
CHANGED
@@ -7,7 +7,6 @@ require "test/support/name_set"
|
|
7
7
|
|
8
8
|
module GGem
|
9
9
|
class SystemTests < Assert::Context
|
10
|
-
|
11
10
|
NS_SIMPLE = GGem::NameSet::Simple
|
12
11
|
NS_UNDER = GGem::NameSet::Underscored
|
13
12
|
NS_HYPHEN = GGem::NameSet::HyphenatedOther
|
@@ -18,7 +17,8 @@ module GGem
|
|
18
17
|
class GemTests < SystemTests
|
19
18
|
desc "Gem"
|
20
19
|
|
21
|
-
should "know its name attrs for various name styles
|
20
|
+
should "know its name attrs for various name styles "\
|
21
|
+
"(simple/underscored/hyphenated)" do
|
22
22
|
[NS_SIMPLE, NS_UNDER, NS_HYPHEN].each do |ns|
|
23
23
|
assert_gem_name_set(ns.new)
|
24
24
|
end
|
@@ -45,7 +45,8 @@ module GGem
|
|
45
45
|
FileUtils.rm_rf(TMP_PATH)
|
46
46
|
end
|
47
47
|
|
48
|
-
should "save gems with various name styles
|
48
|
+
should "save gems with various name styles "\
|
49
|
+
"(simple/underscored/hyphenated)" do
|
49
50
|
[NS_SIMPLE, NS_UNDER, NS_HYPHEN].each do |ns|
|
50
51
|
init_gem = GGem::Gem.new(TMP_PATH, ns.new.variations.first)
|
51
52
|
gem_from_save = init_gem.save!
|
@@ -59,11 +60,11 @@ module GGem
|
|
59
60
|
|
60
61
|
def assert_gem_created(name_set)
|
61
62
|
folders = name_set.expected_folders
|
62
|
-
files
|
63
|
-
paths
|
63
|
+
files = name_set.expected_files
|
64
|
+
paths = (folders + files).map{ |p| File.join(TMP_PATH, name_set.name, p) }
|
64
65
|
|
65
66
|
paths.flatten.each do |path|
|
66
|
-
assert File.
|
67
|
+
assert File.exist?(path), "`#{path}` does not exist"
|
67
68
|
end
|
68
69
|
end
|
69
70
|
end
|
data/test/unit/cli_tests.rb
CHANGED
@@ -8,7 +8,7 @@ require "ggem/cli/commands"
|
|
8
8
|
require "ggem/gem"
|
9
9
|
require "ggem/gemspec"
|
10
10
|
require "ggem/git_repo"
|
11
|
-
require "much-
|
11
|
+
require "much-mixin"
|
12
12
|
|
13
13
|
class GGem::CLI
|
14
14
|
class UnitTests < Assert::Context
|
@@ -147,7 +147,7 @@ class GGem::CLI
|
|
147
147
|
class RunWithHelpTests < RunSetupTests
|
148
148
|
desc "and run with the help switch"
|
149
149
|
setup do
|
150
|
-
@cli.run([
|
150
|
+
@cli.run(["--help"])
|
151
151
|
end
|
152
152
|
|
153
153
|
should "output the invalid command's help" do
|
@@ -163,7 +163,7 @@ class GGem::CLI
|
|
163
163
|
class RunWithVersionTests < RunSetupTests
|
164
164
|
desc "and run with the version switch"
|
165
165
|
setup do
|
166
|
-
@cli.run([
|
166
|
+
@cli.run(["--version"])
|
167
167
|
end
|
168
168
|
|
169
169
|
should "have output its version" do
|
@@ -217,8 +217,8 @@ class GGem::CLI
|
|
217
217
|
end
|
218
218
|
|
219
219
|
should "parse its argv on run" do
|
220
|
-
assert_raises(CLIRB::HelpExit){ subject.new.run([
|
221
|
-
assert_raises(CLIRB::VersionExit){ subject.new.run([
|
220
|
+
assert_raises(CLIRB::HelpExit){ subject.new.run(["--help"]) }
|
221
|
+
assert_raises(CLIRB::VersionExit){ subject.new.run(["--version"]) }
|
222
222
|
end
|
223
223
|
|
224
224
|
should "raise a help exit if its name is empty" do
|
@@ -268,9 +268,10 @@ class GGem::CLI
|
|
268
268
|
end
|
269
269
|
|
270
270
|
should "take custom CLIRB build procs" do
|
271
|
-
cmd =
|
272
|
-
|
273
|
-
|
271
|
+
cmd =
|
272
|
+
@command_class.new do
|
273
|
+
option "test", "testing", abbrev: "t"
|
274
|
+
end
|
274
275
|
cmd.run(["-t"], @stdout, @stderr)
|
275
276
|
assert_true cmd.clirb.opts["test"]
|
276
277
|
end
|
@@ -284,7 +285,7 @@ class GGem::CLI
|
|
284
285
|
desc "GitRepoCommand"
|
285
286
|
setup do
|
286
287
|
@gem1_root_path = TEST_SUPPORT_PATH.join("gem1")
|
287
|
-
Assert.stub(Dir, :pwd){ @gem1_root_path}
|
288
|
+
Assert.stub(Dir, :pwd){ @gem1_root_path }
|
288
289
|
|
289
290
|
@command_class = Class.new{ include GitRepoCommand }
|
290
291
|
@cmd = @command_class.new
|
@@ -305,9 +306,9 @@ class GGem::CLI
|
|
305
306
|
end
|
306
307
|
|
307
308
|
module RootPathTests
|
308
|
-
include
|
309
|
+
include MuchMixin
|
309
310
|
|
310
|
-
|
311
|
+
mixin_included do
|
311
312
|
setup do
|
312
313
|
@root_path = Factory.path
|
313
314
|
Assert.stub(Dir, :pwd){ @root_path }
|
@@ -316,14 +317,16 @@ class GGem::CLI
|
|
316
317
|
end
|
317
318
|
|
318
319
|
module GitRepoSpyTests
|
319
|
-
include
|
320
|
+
include MuchMixin
|
320
321
|
|
321
|
-
|
322
|
+
mixin_included do
|
322
323
|
include RootPathTests
|
323
324
|
|
324
325
|
setup do
|
325
326
|
@repo_spy = nil
|
326
|
-
Assert.stub(GGem::GitRepo, :new)
|
327
|
+
Assert.stub(GGem::GitRepo, :new) do |*args|
|
328
|
+
@repo_spy = GitRepoSpy.new(*args)
|
329
|
+
end
|
327
330
|
end
|
328
331
|
end
|
329
332
|
end
|
@@ -383,17 +386,15 @@ class GGem::CLI
|
|
383
386
|
|
384
387
|
should "re-raise a specific argument error on gem 'no name' errors" do
|
385
388
|
Assert.stub(@gem_class, :new){ raise GGem::Gem::NoNameError }
|
386
|
-
err = nil
|
387
|
-
begin
|
388
|
-
cmd = @command_class.new
|
389
|
-
cmd.run([])
|
390
|
-
rescue ArgumentError => err
|
391
|
-
end
|
392
389
|
|
393
|
-
|
390
|
+
ex =
|
391
|
+
assert_that{
|
392
|
+
cmd = @command_class.new
|
393
|
+
cmd.run([])
|
394
|
+
}.raises(ArgumentError)
|
394
395
|
exp = "GEM-NAME must be provided"
|
395
|
-
assert_equal exp,
|
396
|
-
assert_not_empty
|
396
|
+
assert_equal exp, ex.message
|
397
|
+
assert_not_empty ex.backtrace
|
397
398
|
end
|
398
399
|
end
|
399
400
|
|
@@ -401,7 +402,7 @@ class GGem::CLI
|
|
401
402
|
desc "GemspecCommand"
|
402
403
|
setup do
|
403
404
|
@gem1_root_path = TEST_SUPPORT_PATH.join("gem1")
|
404
|
-
Assert.stub(Dir, :pwd){ @gem1_root_path}
|
405
|
+
Assert.stub(Dir, :pwd){ @gem1_root_path }
|
405
406
|
|
406
407
|
@command_class = Class.new{ include GemspecCommand }
|
407
408
|
@cmd = @command_class.new
|
@@ -424,25 +425,23 @@ class GGem::CLI
|
|
424
425
|
root = Factory.path
|
425
426
|
Assert.stub(Dir, :pwd){ root }
|
426
427
|
|
427
|
-
|
428
|
-
cmd = @command_class.new
|
429
|
-
rescue ArgumentError => err
|
430
|
-
end
|
431
|
-
assert_not_nil err
|
428
|
+
ex = assert_that{ @command_class.new }.raises(ArgumentError)
|
432
429
|
exp = "There are no gemspecs at #{Dir.pwd}"
|
433
|
-
assert_equal exp,
|
430
|
+
assert_equal exp, ex.message
|
434
431
|
end
|
435
432
|
end
|
436
433
|
|
437
434
|
module GemspecSpyTests
|
438
|
-
include
|
435
|
+
include MuchMixin
|
439
436
|
|
440
|
-
|
437
|
+
mixin_included do
|
441
438
|
include RootPathTests
|
442
439
|
|
443
440
|
setup do
|
444
441
|
@spec_spy = nil
|
445
|
-
Assert.stub(GGem::Gemspec, :new)
|
442
|
+
Assert.stub(GGem::Gemspec, :new) do |*args|
|
443
|
+
@spec_spy = GemspecSpy.new(*args)
|
444
|
+
end
|
446
445
|
end
|
447
446
|
end
|
448
447
|
end
|
@@ -481,7 +480,9 @@ class GGem::CLI
|
|
481
480
|
assert_true @spec_spy.run_build_cmd_called
|
482
481
|
|
483
482
|
exp = ENV["DEBUG"] == "1" ? "build\nbuild cmd was run\n" : ""
|
484
|
-
exp +=
|
483
|
+
exp +=
|
484
|
+
"#{@spec_spy.name} #{@spec_spy.version} built to "\
|
485
|
+
"#{@spec_spy.gem_file}\n"
|
485
486
|
assert_equal exp, @stdout.read
|
486
487
|
|
487
488
|
ENV["DEBUG"] = nil
|
@@ -489,7 +490,9 @@ class GGem::CLI
|
|
489
490
|
|
490
491
|
should "handle cmd errors when run" do
|
491
492
|
err_msg = Factory.string
|
492
|
-
Assert.stub(@spec_spy, :run_build_cmd)
|
493
|
+
Assert.stub(@spec_spy, :run_build_cmd) do
|
494
|
+
raise GGem::Gemspec::CmdError, err_msg
|
495
|
+
end
|
493
496
|
|
494
497
|
assert_raises(CommandExitError){ subject.run([], @stdout, @stderr) }
|
495
498
|
assert_equal "#{err_msg}\n", @stderr.read
|
@@ -502,7 +505,9 @@ class GGem::CLI
|
|
502
505
|
desc "InstallCommand"
|
503
506
|
setup do
|
504
507
|
@build_spy = nil
|
505
|
-
Assert.stub(BuildCommand, :new)
|
508
|
+
Assert.stub(BuildCommand, :new) do |*args|
|
509
|
+
@build_spy = CommandSpy.new(*args)
|
510
|
+
end
|
506
511
|
|
507
512
|
@command_class = InstallCommand
|
508
513
|
@cmd = @command_class.new
|
@@ -529,7 +534,8 @@ class GGem::CLI
|
|
529
534
|
assert @build_spy
|
530
535
|
end
|
531
536
|
|
532
|
-
should "run the build command and call the spec's run install cmds when
|
537
|
+
should "run the build command and call the spec's run install cmds when "\
|
538
|
+
"run" do
|
533
539
|
ENV["DEBUG"] = [nil, "1"].sample
|
534
540
|
subject.run(@argv, @stdout, @stderr)
|
535
541
|
|
@@ -546,7 +552,9 @@ class GGem::CLI
|
|
546
552
|
|
547
553
|
should "handle cmd errors when run" do
|
548
554
|
err_msg = Factory.string
|
549
|
-
Assert.stub(@spec_spy, :run_install_cmd)
|
555
|
+
Assert.stub(@spec_spy, :run_install_cmd) do
|
556
|
+
raise GGem::Gemspec::CmdError, err_msg
|
557
|
+
end
|
550
558
|
|
551
559
|
assert_raises(CommandExitError){ subject.run(@argv, @stdout, @stderr) }
|
552
560
|
assert_equal "#{err_msg}\n", @stderr.read
|
@@ -559,7 +567,9 @@ class GGem::CLI
|
|
559
567
|
desc "PushCommand"
|
560
568
|
setup do
|
561
569
|
@build_spy = nil
|
562
|
-
Assert.stub(BuildCommand, :new)
|
570
|
+
Assert.stub(BuildCommand, :new) do |*args|
|
571
|
+
@build_spy = CommandSpy.new(*args)
|
572
|
+
end
|
563
573
|
|
564
574
|
@command_class = PushCommand
|
565
575
|
@cmd = @command_class.new
|
@@ -604,7 +614,9 @@ class GGem::CLI
|
|
604
614
|
|
605
615
|
should "handle cmd errors when run" do
|
606
616
|
err_msg = Factory.string
|
607
|
-
Assert.stub(@spec_spy, :run_push_cmd)
|
617
|
+
Assert.stub(@spec_spy, :run_push_cmd) do
|
618
|
+
raise GGem::Gemspec::CmdError, err_msg
|
619
|
+
end
|
608
620
|
|
609
621
|
assert_raises(CommandExitError){ subject.run(@argv, @stdout, @stderr) }
|
610
622
|
assert_equal "#{err_msg}\n", @stderr.read
|
@@ -670,13 +682,14 @@ class GGem::CLI
|
|
670
682
|
assert_true @repo_spy.run_push_cmd_called
|
671
683
|
assert_nil @repo_spy.run_rm_tag_cmd_called_with
|
672
684
|
|
673
|
-
exp =
|
674
|
-
"
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
685
|
+
exp =
|
686
|
+
if ENV["DEBUG"] == "1"
|
687
|
+
"validate clean\nvalidate clean cmd was run\n" \
|
688
|
+
"validate committed\nvalidate committed cmd was run\n" \
|
689
|
+
"add tag\nadd tag cmd was run\n"
|
690
|
+
else
|
691
|
+
""
|
692
|
+
end
|
680
693
|
exp += "Tagged #{@spec_spy.version_tag}.\n"
|
681
694
|
exp += ENV["DEBUG"] == "1" ? "push\npush cmd was run\n" : ""
|
682
695
|
exp += "Pushed git commits and tags.\n"
|
@@ -717,7 +730,9 @@ class GGem::CLI
|
|
717
730
|
|
718
731
|
should "remove the version tag on push errors" do
|
719
732
|
err_msg = Factory.string
|
720
|
-
Assert.stub(@repo_spy, :run_push_cmd)
|
733
|
+
Assert.stub(@repo_spy, :run_push_cmd) do
|
734
|
+
raise GGem::GitRepo::CmdError, err_msg
|
735
|
+
end
|
721
736
|
|
722
737
|
assert_raises(CommandExitError){ subject.run([], @stdout, @stderr) }
|
723
738
|
assert_equal "#{err_msg}\n", @stderr.read
|
@@ -727,9 +742,13 @@ class GGem::CLI
|
|
727
742
|
end
|
728
743
|
|
729
744
|
should "handle tag removal cmd errors when run" do
|
730
|
-
Assert.stub(@repo_spy, :run_push_cmd)
|
745
|
+
Assert.stub(@repo_spy, :run_push_cmd) do
|
746
|
+
raise GGem::GitRepo::CmdError, Factory.string
|
747
|
+
end
|
731
748
|
err_msg = Factory.string
|
732
|
-
Assert.stub(@repo_spy, :run_rm_tag_cmd)
|
749
|
+
Assert.stub(@repo_spy, :run_rm_tag_cmd) do
|
750
|
+
raise GGem::GitRepo::CmdError, err_msg
|
751
|
+
end
|
733
752
|
|
734
753
|
assert_raises(CommandExitError){ subject.run([], @stdout, @stderr) }
|
735
754
|
assert_equal "#{err_msg}\n", @stderr.read
|
@@ -745,7 +764,9 @@ class GGem::CLI
|
|
745
764
|
Assert.stub(TagCommand, :new){ |*args| @tag_spy = CommandSpy.new(*args) }
|
746
765
|
|
747
766
|
@push_spy = nil
|
748
|
-
Assert.stub(PushCommand, :new)
|
767
|
+
Assert.stub(PushCommand, :new) do |*args|
|
768
|
+
@push_spy = CommandSpy.new(*args)
|
769
|
+
end
|
749
770
|
|
750
771
|
@command_class = ReleaseCommand
|
751
772
|
@cmd = @command_class.new
|
@@ -757,8 +778,9 @@ class GGem::CLI
|
|
757
778
|
end
|
758
779
|
|
759
780
|
should "know its summary" do
|
760
|
-
exp =
|
761
|
-
|
781
|
+
exp =
|
782
|
+
"Tag #{@spec_spy.version_tag} and push built "\
|
783
|
+
"#{@spec_spy.gem_file_name} to #{@spec_spy.push_host}"
|
762
784
|
assert_equal exp, subject.summary
|
763
785
|
end
|
764
786
|
|
@@ -937,7 +959,8 @@ class GGem::CLI
|
|
937
959
|
|
938
960
|
class GemspecSpy
|
939
961
|
attr_reader :name, :version, :version_tag, :push_host
|
940
|
-
attr_reader :run_build_cmd_called, :run_install_cmd_called
|
962
|
+
attr_reader :run_build_cmd_called, :run_install_cmd_called
|
963
|
+
attr_reader :run_push_cmd_called
|
941
964
|
|
942
965
|
def initialize(root_path)
|
943
966
|
@root = Pathname.new(File.expand_path(root_path))
|
@@ -952,15 +975,15 @@ class GGem::CLI
|
|
952
975
|
end
|
953
976
|
|
954
977
|
def path
|
955
|
-
@root.join("#{
|
978
|
+
@root.join("#{name}.gemspec")
|
956
979
|
end
|
957
980
|
|
958
981
|
def gem_file_name
|
959
|
-
"#{
|
982
|
+
"#{name}-#{version}.gem"
|
960
983
|
end
|
961
984
|
|
962
985
|
def gem_file
|
963
|
-
File.join(GGem::Gemspec::BUILD_TO_DIRNAME,
|
986
|
+
File.join(GGem::Gemspec::BUILD_TO_DIRNAME, gem_file_name)
|
964
987
|
end
|
965
988
|
|
966
989
|
def run_build_cmd
|
@@ -982,8 +1005,10 @@ class GGem::CLI
|
|
982
1005
|
class GitRepoSpy
|
983
1006
|
attr_reader :path
|
984
1007
|
attr_reader :run_init_cmd_called
|
985
|
-
attr_reader :run_validate_clean_cmd_called
|
986
|
-
attr_reader :
|
1008
|
+
attr_reader :run_validate_clean_cmd_called
|
1009
|
+
attr_reader :run_validate_committed_cmd_called
|
1010
|
+
attr_reader :run_add_version_tag_cmd_called_with
|
1011
|
+
attr_reader :run_rm_tag_cmd_called_with
|
987
1012
|
attr_reader :run_push_cmd_called
|
988
1013
|
|
989
1014
|
def initialize(path)
|