ggem 1.8.1 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/Gemfile +3 -1
- data/README.md +2 -2
- data/bin/ggem +1 -1
- data/ggem.gemspec +8 -6
- data/lib/ggem.rb +2 -2
- data/lib/ggem/cli.rb +49 -54
- data/lib/ggem/cli/clirb.rb +44 -48
- data/lib/ggem/cli/commands.rb +23 -56
- data/lib/ggem/gem.rb +43 -43
- data/lib/ggem/gemspec.rb +68 -73
- data/lib/ggem/git_repo.rb +39 -44
- data/lib/ggem/template.rb +52 -54
- data/lib/ggem/template_file/Gemfile.erb +3 -1
- data/lib/ggem/template_file/README.md.erb +4 -4
- data/lib/ggem/template_file/gemspec.erb +10 -8
- data/lib/ggem/template_file/lib.rb.erb +2 -2
- data/lib/ggem/template_file/lib_version.rb.erb +1 -1
- data/lib/ggem/template_file/ruby-version.erb +1 -0
- data/lib/ggem/template_file/test_helper.rb.erb +2 -11
- data/lib/ggem/template_file/test_support_factory.rb.erb +1 -2
- data/lib/ggem/version.rb +1 -1
- data/log/.keep +0 -0
- data/test/helper.rb +6 -15
- data/test/support/cmd_tests_helpers.rb +35 -40
- data/test/support/factory.rb +1 -2
- data/test/support/gem1/gem1.gemspec +1 -1
- data/test/support/gem2/gem2.gemspec +2 -2
- data/test/support/name_set.rb +53 -53
- data/test/system/ggem_tests.rb +7 -12
- data/test/unit/cli_tests.rb +100 -121
- data/test/unit/gem_tests.rb +1 -5
- data/test/unit/gemspec_tests.rb +19 -26
- data/test/unit/git_repo_tests.rb +3 -14
- metadata +64 -57
- data/.gitignore +0 -19
data/test/unit/cli_tests.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "assert"
|
2
|
+
require "ggem/cli"
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
4
|
+
require "ggem/cli/clirb"
|
5
|
+
require "ggem/cli/commands"
|
6
|
+
require "ggem/gem"
|
7
|
+
require "ggem/gemspec"
|
8
|
+
require "ggem/git_repo"
|
9
|
+
require "much-plugin"
|
10
10
|
|
11
11
|
class GGem::CLI
|
12
|
-
|
13
12
|
class UnitTests < Assert::Context
|
14
13
|
desc "GGem::CLI"
|
15
14
|
setup do
|
@@ -33,21 +32,20 @@ class GGem::CLI
|
|
33
32
|
|
34
33
|
assert_instance_of InvalidCommand, COMMANDS[Factory.string]
|
35
34
|
|
36
|
-
assert_instance_of GenerateCommand, COMMANDS[
|
37
|
-
assert_instance_of BuildCommand, COMMANDS[
|
38
|
-
assert_instance_of InstallCommand, COMMANDS[
|
39
|
-
assert_instance_of PushCommand, COMMANDS[
|
40
|
-
assert_instance_of TagCommand, COMMANDS[
|
41
|
-
assert_instance_of ReleaseCommand, COMMANDS[
|
35
|
+
assert_instance_of GenerateCommand, COMMANDS["generate"]
|
36
|
+
assert_instance_of BuildCommand, COMMANDS["build"]
|
37
|
+
assert_instance_of InstallCommand, COMMANDS["install"]
|
38
|
+
assert_instance_of PushCommand, COMMANDS["push"]
|
39
|
+
assert_instance_of TagCommand, COMMANDS["tag"]
|
40
|
+
assert_instance_of ReleaseCommand, COMMANDS["release"]
|
42
41
|
|
43
|
-
assert_same COMMANDS[
|
44
|
-
assert_same COMMANDS[
|
45
|
-
assert_same COMMANDS[
|
46
|
-
assert_same COMMANDS[
|
47
|
-
assert_same COMMANDS[
|
48
|
-
assert_same COMMANDS[
|
42
|
+
assert_same COMMANDS["generate"], COMMANDS["g"]
|
43
|
+
assert_same COMMANDS["build"], COMMANDS["b"]
|
44
|
+
assert_same COMMANDS["install"], COMMANDS["i"]
|
45
|
+
assert_same COMMANDS["push"], COMMANDS["p"]
|
46
|
+
assert_same COMMANDS["tag"], COMMANDS["t"]
|
47
|
+
assert_same COMMANDS["release"], COMMANDS["r"]
|
49
48
|
end
|
50
|
-
|
51
49
|
end
|
52
50
|
|
53
51
|
class InitTests < UnitTests
|
@@ -62,7 +60,6 @@ class GGem::CLI
|
|
62
60
|
subject{ @cli }
|
63
61
|
|
64
62
|
should have_imeths :run
|
65
|
-
|
66
63
|
end
|
67
64
|
|
68
65
|
class RunSetupTests < InitTests
|
@@ -71,7 +68,7 @@ class GGem::CLI
|
|
71
68
|
@argv = [@command_name, Factory.string]
|
72
69
|
|
73
70
|
@command_class = Class.new
|
74
|
-
@command_spy
|
71
|
+
@command_spy = CommandSpy.new
|
75
72
|
Assert.stub(@command_class, :new){ @command_spy }
|
76
73
|
COMMANDS.add(@command_class, @command_name)
|
77
74
|
|
@@ -80,7 +77,6 @@ class GGem::CLI
|
|
80
77
|
teardown do
|
81
78
|
COMMANDS.remove(@command_name)
|
82
79
|
end
|
83
|
-
|
84
80
|
end
|
85
81
|
|
86
82
|
class RunTests < RunSetupTests
|
@@ -96,7 +92,6 @@ class GGem::CLI
|
|
96
92
|
should "have successfully exited" do
|
97
93
|
assert_equal 0, @kernel_spy.exit_status
|
98
94
|
end
|
99
|
-
|
100
95
|
end
|
101
96
|
|
102
97
|
class RunWithNoArgsTests < RunSetupTests
|
@@ -113,7 +108,6 @@ class GGem::CLI
|
|
113
108
|
should "have successfully exited" do
|
114
109
|
assert_equal 0, @kernel_spy.exit_status
|
115
110
|
end
|
116
|
-
|
117
111
|
end
|
118
112
|
|
119
113
|
class RunWithInvalidCommandTests < RunSetupTests
|
@@ -125,7 +119,7 @@ class GGem::CLI
|
|
125
119
|
end
|
126
120
|
|
127
121
|
should "output that it is invalid and output the invalid command's help" do
|
128
|
-
exp = "
|
122
|
+
exp = "`#{@name}` is not a command.\n\n"
|
129
123
|
assert_equal exp, @stderr.read
|
130
124
|
assert_equal @invalid_command.help, @stdout.read
|
131
125
|
end
|
@@ -133,7 +127,6 @@ class GGem::CLI
|
|
133
127
|
should "have unsuccessfully exited" do
|
134
128
|
assert_equal 1, @kernel_spy.exit_status
|
135
129
|
end
|
136
|
-
|
137
130
|
end
|
138
131
|
|
139
132
|
class RunWithCommandExitErrorTests < RunSetupTests
|
@@ -147,13 +140,12 @@ class GGem::CLI
|
|
147
140
|
assert_equal 1, @kernel_spy.exit_status
|
148
141
|
assert_empty @stderr.read
|
149
142
|
end
|
150
|
-
|
151
143
|
end
|
152
144
|
|
153
145
|
class RunWithHelpTests < RunSetupTests
|
154
146
|
desc "and run with the help switch"
|
155
147
|
setup do
|
156
|
-
@cli.run([
|
148
|
+
@cli.run([ "--help" ])
|
157
149
|
end
|
158
150
|
|
159
151
|
should "output the invalid command's help" do
|
@@ -164,13 +156,12 @@ class GGem::CLI
|
|
164
156
|
should "have successfully exited" do
|
165
157
|
assert_equal 0, @kernel_spy.exit_status
|
166
158
|
end
|
167
|
-
|
168
159
|
end
|
169
160
|
|
170
161
|
class RunWithVersionTests < RunSetupTests
|
171
162
|
desc "and run with the version switch"
|
172
163
|
setup do
|
173
|
-
@cli.run([
|
164
|
+
@cli.run([ "--version" ])
|
174
165
|
end
|
175
166
|
|
176
167
|
should "have output its version" do
|
@@ -181,7 +172,6 @@ class GGem::CLI
|
|
181
172
|
should "have successfully exited" do
|
182
173
|
assert_equal 0, @kernel_spy.exit_status
|
183
174
|
end
|
184
|
-
|
185
175
|
end
|
186
176
|
|
187
177
|
class RunWithErrorTests < RunSetupTests
|
@@ -201,7 +191,6 @@ class GGem::CLI
|
|
201
191
|
should "have unsuccessfully exited" do
|
202
192
|
assert_equal 1, @kernel_spy.exit_status
|
203
193
|
end
|
204
|
-
|
205
194
|
end
|
206
195
|
|
207
196
|
class InvalidCommandTests < UnitTests
|
@@ -226,12 +215,12 @@ class GGem::CLI
|
|
226
215
|
end
|
227
216
|
|
228
217
|
should "parse its argv on run" do
|
229
|
-
assert_raises(CLIRB::HelpExit){ subject.new.run([
|
230
|
-
assert_raises(CLIRB::VersionExit){ subject.new.run([
|
218
|
+
assert_raises(CLIRB::HelpExit){ subject.new.run([ "--help" ]) }
|
219
|
+
assert_raises(CLIRB::VersionExit){ subject.new.run([ "--version" ]) }
|
231
220
|
end
|
232
221
|
|
233
222
|
should "raise a help exit if its name is empty" do
|
234
|
-
cmd = @command_class.new([nil,
|
223
|
+
cmd = @command_class.new([nil, ""].sample)
|
235
224
|
argv = [Factory.string, Factory.string]
|
236
225
|
assert_raises(CLIRB::HelpExit){ cmd.new.run(argv) }
|
237
226
|
end
|
@@ -247,15 +236,14 @@ class GGem::CLI
|
|
247
236
|
"#{COMMANDS.to_s.split("\n").map{ |l| " #{l}" }.join("\n")}\n"
|
248
237
|
assert_equal exp, subject.help
|
249
238
|
end
|
250
|
-
|
251
239
|
end
|
252
240
|
|
253
241
|
class IOCommandTests < UnitTests
|
254
242
|
setup do
|
243
|
+
@argv = [Factory.string]
|
255
244
|
@stdout, @stderr = IOSpy.new, IOSpy.new
|
256
245
|
end
|
257
246
|
subject{ @cmd }
|
258
|
-
|
259
247
|
end
|
260
248
|
|
261
249
|
class ValidCommandTests < IOCommandTests
|
@@ -279,22 +267,21 @@ class GGem::CLI
|
|
279
267
|
|
280
268
|
should "take custom CLIRB build procs" do
|
281
269
|
cmd = @command_class.new do
|
282
|
-
option
|
270
|
+
option "test", "testing", :abbrev => "t"
|
283
271
|
end
|
284
|
-
cmd.run([
|
285
|
-
assert_true cmd.clirb.opts[
|
272
|
+
cmd.run(["-t"], @stdout, @stderr)
|
273
|
+
assert_true cmd.clirb.opts["test"]
|
286
274
|
end
|
287
275
|
|
288
276
|
should "default its summary" do
|
289
|
-
assert_equal
|
277
|
+
assert_equal "", subject.summary
|
290
278
|
end
|
291
|
-
|
292
279
|
end
|
293
280
|
|
294
281
|
class GitRepoCommandTests < IOCommandTests
|
295
282
|
desc "GitRepoCommand"
|
296
283
|
setup do
|
297
|
-
@gem1_root_path = TEST_SUPPORT_PATH.join(
|
284
|
+
@gem1_root_path = TEST_SUPPORT_PATH.join("gem1")
|
298
285
|
Assert.stub(Dir, :pwd){ @gem1_root_path}
|
299
286
|
|
300
287
|
@command_class = Class.new{ include GitRepoCommand }
|
@@ -313,7 +300,6 @@ class GGem::CLI
|
|
313
300
|
@command_class.new
|
314
301
|
assert_equal [Dir.pwd], gitrepo_new_called_with
|
315
302
|
end
|
316
|
-
|
317
303
|
end
|
318
304
|
|
319
305
|
module RootPathTests
|
@@ -325,7 +311,6 @@ class GGem::CLI
|
|
325
311
|
Assert.stub(Dir, :pwd){ @root_path }
|
326
312
|
end
|
327
313
|
end
|
328
|
-
|
329
314
|
end
|
330
315
|
|
331
316
|
module GitRepoSpyTests
|
@@ -338,9 +323,7 @@ class GGem::CLI
|
|
338
323
|
@repo_spy = nil
|
339
324
|
Assert.stub(GGem::GitRepo, :new){ |*args| @repo_spy = GitRepoSpy.new(*args) }
|
340
325
|
end
|
341
|
-
|
342
326
|
end
|
343
|
-
|
344
327
|
end
|
345
328
|
|
346
329
|
class GenerateCommandTests < IOCommandTests
|
@@ -410,13 +393,12 @@ class GGem::CLI
|
|
410
393
|
assert_equal exp, err.message
|
411
394
|
assert_not_empty err.backtrace
|
412
395
|
end
|
413
|
-
|
414
396
|
end
|
415
397
|
|
416
398
|
class GemspecCommandTests < IOCommandTests
|
417
399
|
desc "GemspecCommand"
|
418
400
|
setup do
|
419
|
-
@gem1_root_path = TEST_SUPPORT_PATH.join(
|
401
|
+
@gem1_root_path = TEST_SUPPORT_PATH.join("gem1")
|
420
402
|
Assert.stub(Dir, :pwd){ @gem1_root_path}
|
421
403
|
|
422
404
|
@command_class = Class.new{ include GemspecCommand }
|
@@ -448,7 +430,6 @@ class GGem::CLI
|
|
448
430
|
exp = "There are no gemspecs at #{Dir.pwd}"
|
449
431
|
assert_equal exp, err.message
|
450
432
|
end
|
451
|
-
|
452
433
|
end
|
453
434
|
|
454
435
|
module GemspecSpyTests
|
@@ -462,7 +443,6 @@ class GGem::CLI
|
|
462
443
|
Assert.stub(GGem::Gemspec, :new){ |*args| @spec_spy = GemspecSpy.new(*args) }
|
463
444
|
end
|
464
445
|
end
|
465
|
-
|
466
446
|
end
|
467
447
|
|
468
448
|
class BuildCommandTests < IOCommandTests
|
@@ -493,16 +473,16 @@ class GGem::CLI
|
|
493
473
|
end
|
494
474
|
|
495
475
|
should "call the spec's run build cmd when run" do
|
496
|
-
ENV[
|
476
|
+
ENV["DEBUG"] = [nil, "1"].sample
|
497
477
|
subject.run([], @stdout, @stderr)
|
498
478
|
|
499
479
|
assert_true @spec_spy.run_build_cmd_called
|
500
480
|
|
501
|
-
exp = ENV[
|
481
|
+
exp = ENV["DEBUG"] == "1" ? "build\nbuild cmd was run\n" : ""
|
502
482
|
exp += "#{@spec_spy.name} #{@spec_spy.version} built to #{@spec_spy.gem_file}\n"
|
503
483
|
assert_equal exp, @stdout.read
|
504
484
|
|
505
|
-
ENV[
|
485
|
+
ENV["DEBUG"] = nil
|
506
486
|
end
|
507
487
|
|
508
488
|
should "handle cmd errors when run" do
|
@@ -512,7 +492,6 @@ class GGem::CLI
|
|
512
492
|
assert_raises(CommandExitError){ subject.run([], @stdout, @stderr) }
|
513
493
|
assert_equal "#{err_msg}\n", @stderr.read
|
514
494
|
end
|
515
|
-
|
516
495
|
end
|
517
496
|
|
518
497
|
class InstallCommandTests < IOCommandTests
|
@@ -524,7 +503,6 @@ class GGem::CLI
|
|
524
503
|
Assert.stub(BuildCommand, :new){ |*args| @build_spy = CommandSpy.new(*args) }
|
525
504
|
|
526
505
|
@command_class = InstallCommand
|
527
|
-
@argv = []
|
528
506
|
@cmd = @command_class.new
|
529
507
|
end
|
530
508
|
|
@@ -545,23 +523,23 @@ class GGem::CLI
|
|
545
523
|
assert_equal exp, subject.help
|
546
524
|
end
|
547
525
|
|
548
|
-
should "build a build command
|
526
|
+
should "build a build command" do
|
549
527
|
assert @build_spy
|
550
528
|
end
|
551
529
|
|
552
530
|
should "run the build command and call the spec's run install cmds when run" do
|
553
|
-
ENV[
|
531
|
+
ENV["DEBUG"] = [nil, "1"].sample
|
554
532
|
subject.run(@argv, @stdout, @stderr)
|
555
533
|
|
556
534
|
assert_true @build_spy.run_called
|
557
|
-
assert_equal
|
535
|
+
assert_equal [], @build_spy.argv
|
558
536
|
assert_true @spec_spy.run_install_cmd_called
|
559
537
|
|
560
|
-
exp = ENV[
|
538
|
+
exp = ENV["DEBUG"] == "1" ? "install\ninstall cmd was run\n" : ""
|
561
539
|
exp += "#{@spec_spy.name} #{@spec_spy.version} installed to system gems\n"
|
562
540
|
assert_includes exp, @stdout.read
|
563
541
|
|
564
|
-
ENV[
|
542
|
+
ENV["DEBUG"] = nil
|
565
543
|
end
|
566
544
|
|
567
545
|
should "handle cmd errors when run" do
|
@@ -571,7 +549,6 @@ class GGem::CLI
|
|
571
549
|
assert_raises(CommandExitError){ subject.run(@argv, @stdout, @stderr) }
|
572
550
|
assert_equal "#{err_msg}\n", @stderr.read
|
573
551
|
end
|
574
|
-
|
575
552
|
end
|
576
553
|
|
577
554
|
class PushCommandTests < IOCommandTests
|
@@ -583,7 +560,6 @@ class GGem::CLI
|
|
583
560
|
Assert.stub(BuildCommand, :new){ |*args| @build_spy = CommandSpy.new(*args) }
|
584
561
|
|
585
562
|
@command_class = PushCommand
|
586
|
-
@argv = []
|
587
563
|
@cmd = @command_class.new
|
588
564
|
end
|
589
565
|
|
@@ -604,24 +580,24 @@ class GGem::CLI
|
|
604
580
|
assert_equal exp, subject.help
|
605
581
|
end
|
606
582
|
|
607
|
-
should "build a build command
|
583
|
+
should "build a build command" do
|
608
584
|
assert @build_spy
|
609
585
|
end
|
610
586
|
|
611
587
|
should "run the build command and call the spec's run push cmds when run" do
|
612
|
-
ENV[
|
588
|
+
ENV["DEBUG"] = [nil, "1"].sample
|
613
589
|
subject.run(@argv, @stdout, @stderr)
|
614
590
|
|
615
591
|
assert_true @build_spy.run_called
|
616
|
-
assert_equal
|
592
|
+
assert_equal [], @build_spy.argv
|
617
593
|
assert_true @spec_spy.run_push_cmd_called
|
618
594
|
|
619
595
|
exp = "Pushing #{@spec_spy.gem_file_name} to #{@spec_spy.push_host}...\n"
|
620
|
-
exp += ENV[
|
596
|
+
exp += ENV["DEBUG"] == "1" ? "push\npush cmd was run\n" : ""
|
621
597
|
exp += "#{@spec_spy.gem_file_name} received.\n"
|
622
598
|
assert_equal exp, @stdout.read
|
623
599
|
|
624
|
-
ENV[
|
600
|
+
ENV["DEBUG"] = nil
|
625
601
|
end
|
626
602
|
|
627
603
|
should "handle cmd errors when run" do
|
@@ -631,7 +607,6 @@ class GGem::CLI
|
|
631
607
|
assert_raises(CommandExitError){ subject.run(@argv, @stdout, @stderr) }
|
632
608
|
assert_equal "#{err_msg}\n", @stderr.read
|
633
609
|
end
|
634
|
-
|
635
610
|
end
|
636
611
|
|
637
612
|
class ForceTagOptionCommandTests < IOCommandTests
|
@@ -646,10 +621,9 @@ class GGem::CLI
|
|
646
621
|
end
|
647
622
|
|
648
623
|
should "add a force-tag CLIRB option" do
|
649
|
-
subject.run([
|
650
|
-
assert_true subject.clirb.opts[
|
624
|
+
subject.run(["-f"], @stdout, @stderr)
|
625
|
+
assert_true subject.clirb.opts["force-tag"]
|
651
626
|
end
|
652
|
-
|
653
627
|
end
|
654
628
|
|
655
629
|
class TagCommandTests < IOCommandTests
|
@@ -663,8 +637,8 @@ class GGem::CLI
|
|
663
637
|
end
|
664
638
|
|
665
639
|
should "be a git repo, gemspec, force tag option command" do
|
666
|
-
assert_kind_of GitRepoCommand,
|
667
|
-
assert_kind_of GemspecCommand,
|
640
|
+
assert_kind_of GitRepoCommand, subject
|
641
|
+
assert_kind_of GemspecCommand, subject
|
668
642
|
assert_kind_of ForceTagOptionCommand, subject
|
669
643
|
end
|
670
644
|
|
@@ -682,7 +656,7 @@ class GGem::CLI
|
|
682
656
|
end
|
683
657
|
|
684
658
|
should "call the repo's run build/push cmds when run" do
|
685
|
-
ENV[
|
659
|
+
ENV["DEBUG"] = [nil, "1"].sample
|
686
660
|
subject.run([], @stdout, @stderr)
|
687
661
|
|
688
662
|
assert_true @repo_spy.run_validate_clean_cmd_called
|
@@ -694,19 +668,19 @@ class GGem::CLI
|
|
694
668
|
assert_true @repo_spy.run_push_cmd_called
|
695
669
|
assert_nil @repo_spy.run_rm_tag_cmd_called_with
|
696
670
|
|
697
|
-
exp = if ENV[
|
671
|
+
exp = if ENV["DEBUG"] == "1"
|
698
672
|
"validate clean\nvalidate clean cmd was run\n" \
|
699
673
|
"validate committed\nvalidate committed cmd was run\n" \
|
700
674
|
"add tag\nadd tag cmd was run\n"
|
701
675
|
else
|
702
|
-
|
676
|
+
""
|
703
677
|
end
|
704
678
|
exp += "Tagged #{@spec_spy.version_tag}.\n"
|
705
|
-
exp += ENV[
|
679
|
+
exp += ENV["DEBUG"] == "1" ? "push\npush cmd was run\n" : ""
|
706
680
|
exp += "Pushed git commits and tags.\n"
|
707
681
|
assert_equal exp, @stdout.read
|
708
682
|
|
709
|
-
ENV[
|
683
|
+
ENV["DEBUG"] = nil
|
710
684
|
end
|
711
685
|
|
712
686
|
should "handle validation cmd errors when run" do
|
@@ -724,7 +698,7 @@ class GGem::CLI
|
|
724
698
|
err_on = [:run_validate_clean_cmd, :run_validate_committed_cmd].sample
|
725
699
|
Assert.stub(@repo_spy, err_on){ raise GGem::GitRepo::CmdError, err_msg }
|
726
700
|
|
727
|
-
subject.run([
|
701
|
+
subject.run([["--force-tag", "-f"].sample], @stdout, @stderr)
|
728
702
|
exp = "There are files that need to be committed first.\n" \
|
729
703
|
"Forcing tag anyway...\n"
|
730
704
|
assert_equal exp, @stderr.read
|
@@ -758,7 +732,6 @@ class GGem::CLI
|
|
758
732
|
assert_raises(CommandExitError){ subject.run([], @stdout, @stderr) }
|
759
733
|
assert_equal "#{err_msg}\n", @stderr.read
|
760
734
|
end
|
761
|
-
|
762
735
|
end
|
763
736
|
|
764
737
|
class ReleaseCommandTests < IOCommandTests
|
@@ -773,12 +746,11 @@ class GGem::CLI
|
|
773
746
|
Assert.stub(PushCommand, :new){ |*args| @push_spy = CommandSpy.new(*args) }
|
774
747
|
|
775
748
|
@command_class = ReleaseCommand
|
776
|
-
@argv = []
|
777
749
|
@cmd = @command_class.new
|
778
750
|
end
|
779
751
|
|
780
752
|
should "be a gemspec, force tag option command" do
|
781
|
-
assert_kind_of GemspecCommand,
|
753
|
+
assert_kind_of GemspecCommand, subject
|
782
754
|
assert_kind_of ForceTagOptionCommand, subject
|
783
755
|
end
|
784
756
|
|
@@ -797,7 +769,7 @@ class GGem::CLI
|
|
797
769
|
assert_equal exp, subject.help
|
798
770
|
end
|
799
771
|
|
800
|
-
should "build a tag and push command
|
772
|
+
should "build a tag and push command" do
|
801
773
|
[@tag_spy, @push_spy].each do |spy|
|
802
774
|
assert spy
|
803
775
|
end
|
@@ -806,12 +778,23 @@ class GGem::CLI
|
|
806
778
|
should "run the tag and push command when run" do
|
807
779
|
subject.run(@argv, @stdout, @stderr)
|
808
780
|
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
781
|
+
assert_true @tag_spy.run_called
|
782
|
+
assert_equal [], @tag_spy.argv
|
783
|
+
|
784
|
+
assert_true @push_spy.run_called
|
785
|
+
assert_equal [], @push_spy.argv
|
813
786
|
end
|
814
787
|
|
788
|
+
should "pass any force-tag option to the tag cmd but not the release cmd" do
|
789
|
+
force_tag_argv = [["--force-tag", "-f"].sample]
|
790
|
+
subject.run(force_tag_argv, @stdout, @stderr)
|
791
|
+
|
792
|
+
assert_true @tag_spy.run_called
|
793
|
+
assert_equal ["--force-tag"], @tag_spy.argv
|
794
|
+
|
795
|
+
assert_true @push_spy.run_called
|
796
|
+
assert_equal [], @push_spy.argv
|
797
|
+
end
|
815
798
|
end
|
816
799
|
|
817
800
|
class CommandSetTests < UnitTests
|
@@ -826,41 +809,41 @@ class GGem::CLI
|
|
826
809
|
|
827
810
|
should "add/rm commands, be able to look them up and know its size" do
|
828
811
|
assert_equal 0, subject.size
|
829
|
-
assert_equal
|
812
|
+
assert_equal "", subject.to_s
|
830
813
|
|
831
|
-
subject.add(CommandSpy,
|
814
|
+
subject.add(CommandSpy, "test", "t", "tst")
|
832
815
|
assert_equal 1, subject.size
|
833
816
|
|
834
|
-
assert_instance_of CommandSpy, subject[
|
835
|
-
assert_same subject[
|
836
|
-
assert_same subject[
|
817
|
+
assert_instance_of CommandSpy, subject["test"]
|
818
|
+
assert_same subject["test"], subject["t"]
|
819
|
+
assert_same subject["test"], subject["tst"]
|
837
820
|
|
838
|
-
exp_strs = ["test (t, tst) # #{subject[
|
821
|
+
exp_strs = ["test (t, tst) # #{subject["test"].summary}"]
|
839
822
|
assert_equal exp_strs.join("\n"), subject.to_s
|
840
823
|
|
841
|
-
subject.add(CommandSpy,
|
842
|
-
exp_strs << "add1 # #{subject[
|
824
|
+
subject.add(CommandSpy, "add1")
|
825
|
+
exp_strs << "add1 # #{subject["add1"].summary}"
|
843
826
|
|
844
827
|
@cmd_spy = CommandSpy.new
|
845
|
-
Assert.stub(@cmd_spy, :summary){ [nil,
|
828
|
+
Assert.stub(@cmd_spy, :summary){ [nil, ""].sample }
|
846
829
|
Assert.stub(CommandSpy, :new){ @cmd_spy }
|
847
830
|
|
848
|
-
subject.add(CommandSpy,
|
831
|
+
subject.add(CommandSpy, "add2", "add")
|
849
832
|
exp_strs << "add2 (add) "
|
850
833
|
|
851
|
-
subject.add(CommandSpy,
|
852
|
-
Assert.stub(subject[
|
834
|
+
subject.add(CommandSpy, "add3")
|
835
|
+
Assert.stub(subject["add3"], :summary){ [nil, ""].sample }
|
853
836
|
exp_strs << "add3 "
|
854
837
|
|
855
838
|
assert_equal exp_strs.join("\n"), subject.to_s
|
856
839
|
|
857
|
-
subject.remove(
|
858
|
-
subject.remove(
|
859
|
-
subject.remove(
|
860
|
-
subject.remove(
|
840
|
+
subject.remove("test")
|
841
|
+
subject.remove("add1")
|
842
|
+
subject.remove("add2")
|
843
|
+
subject.remove("add3")
|
861
844
|
|
862
845
|
assert_equal 0, subject.size
|
863
|
-
assert_equal
|
846
|
+
assert_equal "", subject.to_s
|
864
847
|
end
|
865
848
|
|
866
849
|
should "call the given block when looking up unknown command names" do
|
@@ -868,7 +851,6 @@ class GGem::CLI
|
|
868
851
|
subject[unknown_cmd_name]
|
869
852
|
assert_equal [unknown_cmd_name], @unknown_cmd_block_called_with
|
870
853
|
end
|
871
|
-
|
872
854
|
end
|
873
855
|
|
874
856
|
class CLISpy
|
@@ -981,19 +963,18 @@ class GGem::CLI
|
|
981
963
|
|
982
964
|
def run_build_cmd
|
983
965
|
@run_build_cmd_called = true
|
984
|
-
[
|
966
|
+
["build", 0, "build cmd was run"]
|
985
967
|
end
|
986
968
|
|
987
969
|
def run_install_cmd
|
988
970
|
@run_install_cmd_called = true
|
989
|
-
[
|
971
|
+
["install", 0, "install cmd was run"]
|
990
972
|
end
|
991
973
|
|
992
974
|
def run_push_cmd
|
993
975
|
@run_push_cmd_called = true
|
994
|
-
[
|
976
|
+
["push", 0, "push cmd was run"]
|
995
977
|
end
|
996
|
-
|
997
978
|
end
|
998
979
|
|
999
980
|
class GitRepoSpy
|
@@ -1019,34 +1000,32 @@ class GGem::CLI
|
|
1019
1000
|
|
1020
1001
|
def run_init_cmd
|
1021
1002
|
@run_init_cmd_called = true
|
1022
|
-
[
|
1003
|
+
["init", 0, "init cmd was run"]
|
1023
1004
|
end
|
1024
1005
|
|
1025
1006
|
def run_validate_clean_cmd
|
1026
1007
|
@run_validate_clean_cmd_called = true
|
1027
|
-
[
|
1008
|
+
["validate clean", 0, "validate clean cmd was run"]
|
1028
1009
|
end
|
1029
1010
|
|
1030
1011
|
def run_validate_committed_cmd
|
1031
1012
|
@run_validate_committed_cmd_called = true
|
1032
|
-
[
|
1013
|
+
["validate committed", 0, "validate committed cmd was run"]
|
1033
1014
|
end
|
1034
1015
|
|
1035
1016
|
def run_add_version_tag_cmd(*args)
|
1036
1017
|
@run_add_version_tag_cmd_called_with = args
|
1037
|
-
[
|
1018
|
+
["add tag", 0, "add tag cmd was run"]
|
1038
1019
|
end
|
1039
1020
|
|
1040
1021
|
def run_rm_tag_cmd(*args)
|
1041
1022
|
@run_rm_tag_cmd_called_with = args
|
1042
|
-
[
|
1023
|
+
["rm tag", 0, "rm tag cmd was run"]
|
1043
1024
|
end
|
1044
1025
|
|
1045
1026
|
def run_push_cmd
|
1046
1027
|
@run_push_cmd_called = true
|
1047
|
-
[
|
1028
|
+
["push", 0, "push cmd was run"]
|
1048
1029
|
end
|
1049
|
-
|
1050
1030
|
end
|
1051
|
-
|
1052
1031
|
end
|