ggem 1.9.2 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "pathname"
2
4
  require "scmd"
3
5
 
4
6
  module GGem; end
7
+
5
8
  class GGem::Gemspec
6
9
  PUSH_HOST_META_KEY = "allowed_push_host"
7
- DEFAULT_PUSH_HOST = "https://rubygems.org".freeze
8
- BUILD_TO_DIRNAME = "pkg".freeze
10
+ DEFAULT_PUSH_HOST = "https://rubygems.org"
11
+ BUILD_TO_DIRNAME = "pkg"
9
12
 
10
13
  NotFoundError = Class.new(ArgumentError)
11
14
  LoadError = Class.new(ArgumentError)
@@ -53,25 +56,34 @@ class GGem::Gemspec
53
56
  def run_cmd(cmd_string)
54
57
  cmd = Scmd.new(cmd_string)
55
58
  cmd.run
56
- if !cmd.success?
57
- raise CmdError, "#{cmd_string}\n" \
58
- "#{cmd.stderr.empty? ? cmd.stdout : cmd.stderr}"
59
+ unless cmd.success?
60
+ raise(
61
+ CmdError,
62
+ "#{cmd_string}\n#{cmd.stderr.empty? ? cmd.stdout : cmd.stderr}",
63
+ )
59
64
  end
60
65
  [cmd_string, cmd.exitstatus, cmd.stdout]
61
66
  end
62
67
 
63
68
  def load_gemspec(path)
64
- eval(path.read, TOPLEVEL_BINDING, path.expand_path.to_s)
65
- rescue ScriptError, StandardError => e
66
- original_line = e.backtrace.find{ |line| line.include?(path.to_s) }
67
- msg = "There was a #{e.class} while loading #{path.basename}: \n#{e.message}"
69
+ eval( # rubocop:disable Security/Eval
70
+ path.read,
71
+ TOPLEVEL_BINDING,
72
+ path.expand_path.to_s,
73
+ )
74
+ rescue ScriptError, StandardError => ex
75
+ original_line = ex.backtrace.find{ |line| line.include?(path.to_s) }
76
+ msg =
77
+ "There was a #{ex.class} while loading #{path.basename}: \n#{ex.message}"
68
78
  msg << " from\n #{original_line}" if original_line
69
79
  msg << "\n"
70
80
  raise LoadError, msg
71
81
  end
72
82
 
73
83
  def get_push_host(spec)
74
- ENV["GGEM_PUSH_HOST"] || get_meta(spec)[PUSH_HOST_META_KEY] || DEFAULT_PUSH_HOST
84
+ ENV["GGEM_PUSH_HOST"] ||
85
+ get_meta(spec)[PUSH_HOST_META_KEY] ||
86
+ DEFAULT_PUSH_HOST
75
87
  end
76
88
 
77
89
  def get_meta(spec)
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "pathname"
2
4
  require "scmd"
3
5
 
4
6
  module GGem; end
7
+
5
8
  class GGem::GitRepo
6
9
  NotFoundError = Class.new(ArgumentError)
7
10
  CmdError = Class.new(RuntimeError)
@@ -46,7 +49,7 @@ class GGem::GitRepo
46
49
  cmd_string = "cd #{@path} && #{cmd_string}"
47
50
  cmd = Scmd.new(cmd_string)
48
51
  cmd.run
49
- if !cmd.success?
52
+ unless cmd.success?
50
53
  raise CmdError, "#{cmd_string}\n" \
51
54
  "#{cmd.stderr.empty? ? cmd.stdout : cmd.stderr}"
52
55
  end
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "erb"
2
4
  require "fileutils"
3
5
 
4
6
  module GGem; end
7
+
5
8
  class GGem::Template
6
9
  def initialize(ggem)
7
10
  @ggem = ggem
@@ -16,12 +19,15 @@ class GGem::Template
16
19
  save_folder "log"
17
20
  save_folder "tmp"
18
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")
19
25
  save_file("ruby-version.erb", ".ruby-version")
20
- save_file("gitignore.erb", ".gitignore")
21
- save_file("Gemfile.erb", "Gemfile")
22
- save_file("gemspec.erb", "#{@ggem.name}.gemspec")
23
- save_file("README.md.erb", "README.md")
24
- save_file("LICENSE.erb", "LICENSE")
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")
25
31
 
26
32
  save_file("lib.rb.erb", "lib/#{@ggem.ruby_name}.rb")
27
33
  save_file("lib_version.rb.erb", "lib/#{@ggem.ruby_name}/version.rb")
@@ -37,7 +43,7 @@ class GGem::Template
37
43
 
38
44
  private
39
45
 
40
- def save_folder(relative_path=nil)
46
+ def save_folder(relative_path = nil)
41
47
  path = File.join([@ggem.path, relative_path].compact)
42
48
  FileUtils.mkdir_p(path)
43
49
  end
@@ -51,10 +57,10 @@ class GGem::Template
51
57
  source_file = File.join(File.dirname(__FILE__), "template_file", source)
52
58
  output_file = File.join(@ggem.root_path, @ggem.name, output)
53
59
 
54
- if File.exists?(source_file)
60
+ if File.exist?(source_file)
55
61
  FileUtils.mkdir_p(File.dirname(output_file))
56
62
  erb = ERB.new(File.read(source_file))
57
- File.open(output_file, "w") {|f| f << erb.result(binding) }
63
+ File.open(output_file, "w"){ |f| f << erb.result(binding) }
58
64
  else
59
65
  raise ArgumentError, "the source file `#{source_file}` does not exist"
60
66
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  ruby "~> 2.5"
4
6
 
5
7
  gemspec
6
8
 
7
- gem "pry", "~> 0.12.2"
9
+ gem "pry"
@@ -1,4 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
2
4
  lib = File.expand_path("../lib", __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require "<%= @ggem.ruby_name %>/version"
@@ -13,14 +15,16 @@ Gem::Specification.new do |gem|
13
15
  gem.homepage = "TODO: homepage"
14
16
  gem.license = "MIT"
15
17
 
16
- gem.files = `git ls-files | grep "^[^.]"`.split($/)
18
+ gem.files = `git ls-files | grep "^[^.]"`.split($INPUT_RECORD_SEPARATOR)
19
+
17
20
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
21
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
22
  gem.require_paths = ["lib"]
20
23
 
21
24
  gem.required_ruby_version = "~> 2.5"
22
25
 
23
- gem.add_development_dependency("assert", ["~> 2.18.2"])
26
+ gem.add_development_dependency("much-style-guide", ["~> 0.6.0"])
27
+ gem.add_development_dependency("assert", ["~> 2.19.3"])
24
28
 
25
29
  # TODO: gem.add_dependency("gem-name", ["~> 0.0.0"])
26
30
  end
@@ -4,6 +4,7 @@
4
4
  .rbx/
5
5
  .bundle
6
6
  .config
7
+ .rubocop-*-yml
7
8
  .yardoc
8
9
  Gemfile.lock
9
10
  InstalledFiles
@@ -0,0 +1,8 @@
1
+ # https://github.com/redding/l.rb
2
+
3
+ linters:
4
+ - name: "Rubocop"
5
+ cmd: "bundle exec rubocop"
6
+ extensions:
7
+ - ".rb"
8
+ cli_abbrev: "u"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "<%= @ggem.ruby_name %>/version"
2
4
 
3
5
  module <%= @ggem.module_name %>
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module <%= @ggem.module_name %>
2
4
  VERSION = "0.0.1"
3
5
  end
@@ -0,0 +1,3 @@
1
+ inherit_gem:
2
+ much-style-guide:
3
+ - "lib/much-style-guide/rubocop.yml"
@@ -1 +1 @@
1
- 2.5.5
1
+ 2.5.8
@@ -0,0 +1,6 @@
1
+ # https://github.com/redding/t.rb
2
+
3
+ default_cmd: "bundle exec assert"
4
+ test_dir: "test"
5
+ test_file_suffixes:
6
+ - "_tests.rb"
@@ -1,10 +1,12 @@
1
- # this file is automatically required when you run `assert`
2
- # put any test helpers here
1
+ # frozen_string_literal: true
3
2
 
4
- # add the root dir to the load path
3
+ # This file is automatically required when you run `assert`; put any test
4
+ # helpers here.
5
+
6
+ # Add the root dir to the load path.
5
7
  $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
6
8
 
7
- # require pry for debugging (`binding.pry`)
9
+ # Require pry for debugging (`binding.pry`).
8
10
  require "pry"
9
11
 
10
12
  require "test/support/factory"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert/factory"
2
4
 
3
5
  module Factory
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GGem
2
- VERSION = "1.9.2"
4
+ VERSION = "1.10.1"
3
5
  end
@@ -1,14 +1,16 @@
1
- # this file is automatically required when you run `assert`
2
- # put any test helpers here
1
+ # frozen_string_literal: true
3
2
 
4
- # add the root dir to the load path
3
+ # This file is automatically required when you run `assert`; put any test
4
+ # helpers here.
5
+
6
+ # Add the root dir to the load path.
5
7
  require "pathname"
6
8
  ROOT_PATH = Pathname.new(File.expand_path("../..", __FILE__))
7
9
  $LOAD_PATH.unshift(ROOT_PATH.to_s)
8
10
  TMP_PATH = ROOT_PATH.join("tmp")
9
11
  TEST_SUPPORT_PATH = ROOT_PATH.join("test/support")
10
12
 
11
- # require pry for debugging (`binding.pry`)
13
+ # Require pry for debugging (`binding.pry`).
12
14
  require "pry"
13
15
 
14
16
  require "test/support/factory"
@@ -1,11 +1,14 @@
1
- require "much-plugin"
1
+ # frozen_string_literal: true
2
+
3
+ require "much-mixin"
2
4
  require "scmd"
3
5
 
4
6
  module GGem; end
7
+
5
8
  module GGem::CmdTestsHelpers
6
- include MuchPlugin
9
+ include MuchMixin
7
10
 
8
- plugin_included do
11
+ mixin_included do
9
12
  setup do
10
13
  ENV["SCMD_TEST_MODE"] = "1"
11
14
 
@@ -37,12 +40,11 @@ module GGem::CmdTestsHelpers
37
40
  cmd.stderr = Factory.string
38
41
  @cmd_spy = cmd
39
42
  end
40
- err = nil
41
- begin; run_cmd_block.call; rescue StandardError => err; end
42
43
 
43
- assert_kind_of cmd_error_class, err
44
+ ex =
45
+ assert_that{ run_cmd_block.call }.raises(cmd_error_class)
44
46
  exp = "#{@cmd_spy.cmd_str}\n#{@cmd_spy.stderr}"
45
- assert_equal exp, err.message
47
+ assert_equal exp, ex.message
46
48
  end
47
49
  end
48
50
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert/factory"
2
4
 
3
5
  module Factory
@@ -1,16 +1,17 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
2
4
  Gem::Specification.new do |gem|
3
5
  gem.name = "gem1"
4
6
  gem.version = "0.1.0"
5
7
  gem.authors = []
6
8
  gem.email = []
7
- gem.summary = %q{Gem 1 summary}
8
- gem.description = %q{Gem 1 description}
9
+ gem.summary = "Gem 1 summary"
10
+ gem.description = "Gem 1 description"
9
11
  gem.license = "MIT"
10
12
 
11
13
  gem.files = []
12
14
  gem.executables = []
13
15
  gem.test_files = []
14
16
  gem.require_paths = []
15
-
16
17
  end
@@ -1,11 +1,13 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
3
+
2
4
  Gem::Specification.new do |gem|
3
5
  gem.name = "gem2"
4
6
  gem.version = "0.2.0"
5
7
  gem.authors = []
6
8
  gem.email = []
7
- gem.summary = %q{Gem 2 summary}
8
- gem.description = %q{Gem 2 description}
9
+ gem.summary = "Gem 2 summary"
10
+ gem.description = "Gem 2 description"
9
11
  gem.license = "MIT"
10
12
 
11
13
  gem.metadata["allowed_push_host"] = "http://gems.example.com"
@@ -14,5 +16,4 @@ Gem::Specification.new do |gem|
14
16
  gem.executables = []
15
17
  gem.test_files = []
16
18
  gem.require_paths = []
17
-
18
19
  end
@@ -1,10 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GGem; end
4
+
2
5
  module GGem::NameSet
3
6
  class Base
4
7
  attr_reader :variations, :name, :module_name, :ruby_name
5
8
 
6
9
  def expected_folders
7
- [ "",
10
+ [
11
+ "",
8
12
  "lib",
9
13
  "lib/#{@ruby_name}",
10
14
  "test",
@@ -12,12 +16,13 @@ module GGem::NameSet
12
16
  "test/system",
13
17
  "test/unit",
14
18
  "log",
15
- "tmp"
19
+ "tmp",
16
20
  ]
17
21
  end
18
22
 
19
23
  def expected_files
20
- [ ".ruby-version",
24
+ [
25
+ ".ruby-version",
21
26
  ".gitignore",
22
27
  "Gemfile",
23
28
  "#{@name}.gemspec",
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "ggem"
3
5
 
@@ -5,7 +7,6 @@ require "test/support/name_set"
5
7
 
6
8
  module GGem
7
9
  class SystemTests < Assert::Context
8
-
9
10
  NS_SIMPLE = GGem::NameSet::Simple
10
11
  NS_UNDER = GGem::NameSet::Underscored
11
12
  NS_HYPHEN = GGem::NameSet::HyphenatedOther
@@ -16,7 +17,8 @@ module GGem
16
17
  class GemTests < SystemTests
17
18
  desc "Gem"
18
19
 
19
- should "know its name attrs for various name styles (simple/underscored/hyphenated)" do
20
+ should "know its name attrs for various name styles "\
21
+ "(simple/underscored/hyphenated)" do
20
22
  [NS_SIMPLE, NS_UNDER, NS_HYPHEN].each do |ns|
21
23
  assert_gem_name_set(ns.new)
22
24
  end
@@ -43,7 +45,8 @@ module GGem
43
45
  FileUtils.rm_rf(TMP_PATH)
44
46
  end
45
47
 
46
- should "save gems with various name styles (simple/underscored/hyphenated)" do
48
+ should "save gems with various name styles "\
49
+ "(simple/underscored/hyphenated)" do
47
50
  [NS_SIMPLE, NS_UNDER, NS_HYPHEN].each do |ns|
48
51
  init_gem = GGem::Gem.new(TMP_PATH, ns.new.variations.first)
49
52
  gem_from_save = init_gem.save!
@@ -58,10 +61,12 @@ module GGem
58
61
  def assert_gem_created(name_set)
59
62
  folders = name_set.expected_folders
60
63
  files = name_set.expected_files
61
- paths = (folders + files).collect{ |p| File.join(TMP_PATH, name_set.name, p) }
64
+ paths = (folders + files).collect do |p|
65
+ File.join(TMP_PATH, name_set.name, p)
66
+ end
62
67
 
63
68
  paths.flatten.each do |path|
64
- assert File.exists?(path), "`#{path}` does not exist"
69
+ assert File.exist?(path), "`#{path}` does not exist"
65
70
  end
66
71
  end
67
72
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "assert"
2
4
  require "ggem/cli"
3
5
 
@@ -6,7 +8,7 @@ require "ggem/cli/commands"
6
8
  require "ggem/gem"
7
9
  require "ggem/gemspec"
8
10
  require "ggem/git_repo"
9
- require "much-plugin"
11
+ require "much-mixin"
10
12
 
11
13
  class GGem::CLI
12
14
  class UnitTests < Assert::Context
@@ -145,7 +147,7 @@ class GGem::CLI
145
147
  class RunWithHelpTests < RunSetupTests
146
148
  desc "and run with the help switch"
147
149
  setup do
148
- @cli.run([ "--help" ])
150
+ @cli.run(["--help"])
149
151
  end
150
152
 
151
153
  should "output the invalid command's help" do
@@ -161,7 +163,7 @@ class GGem::CLI
161
163
  class RunWithVersionTests < RunSetupTests
162
164
  desc "and run with the version switch"
163
165
  setup do
164
- @cli.run([ "--version" ])
166
+ @cli.run(["--version"])
165
167
  end
166
168
 
167
169
  should "have output its version" do
@@ -215,8 +217,8 @@ class GGem::CLI
215
217
  end
216
218
 
217
219
  should "parse its argv on run" do
218
- assert_raises(CLIRB::HelpExit){ subject.new.run([ "--help" ]) }
219
- assert_raises(CLIRB::VersionExit){ subject.new.run([ "--version" ]) }
220
+ assert_raises(CLIRB::HelpExit){ subject.new.run(["--help"]) }
221
+ assert_raises(CLIRB::VersionExit){ subject.new.run(["--version"]) }
220
222
  end
221
223
 
222
224
  should "raise a help exit if its name is empty" do
@@ -267,7 +269,7 @@ class GGem::CLI
267
269
 
268
270
  should "take custom CLIRB build procs" do
269
271
  cmd = @command_class.new do
270
- option "test", "testing", :abbrev => "t"
272
+ option "test", "testing", abbrev: "t"
271
273
  end
272
274
  cmd.run(["-t"], @stdout, @stderr)
273
275
  assert_true cmd.clirb.opts["test"]
@@ -282,7 +284,7 @@ class GGem::CLI
282
284
  desc "GitRepoCommand"
283
285
  setup do
284
286
  @gem1_root_path = TEST_SUPPORT_PATH.join("gem1")
285
- Assert.stub(Dir, :pwd){ @gem1_root_path}
287
+ Assert.stub(Dir, :pwd){ @gem1_root_path }
286
288
 
287
289
  @command_class = Class.new{ include GitRepoCommand }
288
290
  @cmd = @command_class.new
@@ -303,9 +305,9 @@ class GGem::CLI
303
305
  end
304
306
 
305
307
  module RootPathTests
306
- include MuchPlugin
308
+ include MuchMixin
307
309
 
308
- plugin_included do
310
+ mixin_included do
309
311
  setup do
310
312
  @root_path = Factory.path
311
313
  Assert.stub(Dir, :pwd){ @root_path }
@@ -314,14 +316,16 @@ class GGem::CLI
314
316
  end
315
317
 
316
318
  module GitRepoSpyTests
317
- include MuchPlugin
319
+ include MuchMixin
318
320
 
319
- plugin_included do
321
+ mixin_included do
320
322
  include RootPathTests
321
323
 
322
324
  setup do
323
325
  @repo_spy = nil
324
- Assert.stub(GGem::GitRepo, :new){ |*args| @repo_spy = GitRepoSpy.new(*args) }
326
+ Assert.stub(GGem::GitRepo, :new) do |*args|
327
+ @repo_spy = GitRepoSpy.new(*args)
328
+ end
325
329
  end
326
330
  end
327
331
  end
@@ -381,17 +385,15 @@ class GGem::CLI
381
385
 
382
386
  should "re-raise a specific argument error on gem 'no name' errors" do
383
387
  Assert.stub(@gem_class, :new){ raise GGem::Gem::NoNameError }
384
- err = nil
385
- begin
386
- cmd = @command_class.new
387
- cmd.run([])
388
- rescue ArgumentError => err
389
- end
390
388
 
391
- assert_not_nil err
389
+ ex =
390
+ assert_that{
391
+ cmd = @command_class.new
392
+ cmd.run([])
393
+ }.raises(ArgumentError)
392
394
  exp = "GEM-NAME must be provided"
393
- assert_equal exp, err.message
394
- assert_not_empty err.backtrace
395
+ assert_equal exp, ex.message
396
+ assert_not_empty ex.backtrace
395
397
  end
396
398
  end
397
399
 
@@ -399,7 +401,7 @@ class GGem::CLI
399
401
  desc "GemspecCommand"
400
402
  setup do
401
403
  @gem1_root_path = TEST_SUPPORT_PATH.join("gem1")
402
- Assert.stub(Dir, :pwd){ @gem1_root_path}
404
+ Assert.stub(Dir, :pwd){ @gem1_root_path }
403
405
 
404
406
  @command_class = Class.new{ include GemspecCommand }
405
407
  @cmd = @command_class.new
@@ -422,25 +424,23 @@ class GGem::CLI
422
424
  root = Factory.path
423
425
  Assert.stub(Dir, :pwd){ root }
424
426
 
425
- begin
426
- cmd = @command_class.new
427
- rescue ArgumentError => err
428
- end
429
- assert_not_nil err
427
+ ex = assert_that{ @command_class.new }.raises(ArgumentError)
430
428
  exp = "There are no gemspecs at #{Dir.pwd}"
431
- assert_equal exp, err.message
429
+ assert_equal exp, ex.message
432
430
  end
433
431
  end
434
432
 
435
433
  module GemspecSpyTests
436
- include MuchPlugin
434
+ include MuchMixin
437
435
 
438
- plugin_included do
436
+ mixin_included do
439
437
  include RootPathTests
440
438
 
441
439
  setup do
442
440
  @spec_spy = nil
443
- Assert.stub(GGem::Gemspec, :new){ |*args| @spec_spy = GemspecSpy.new(*args) }
441
+ Assert.stub(GGem::Gemspec, :new) do |*args|
442
+ @spec_spy = GemspecSpy.new(*args)
443
+ end
444
444
  end
445
445
  end
446
446
  end
@@ -479,7 +479,9 @@ class GGem::CLI
479
479
  assert_true @spec_spy.run_build_cmd_called
480
480
 
481
481
  exp = ENV["DEBUG"] == "1" ? "build\nbuild cmd was run\n" : ""
482
- exp += "#{@spec_spy.name} #{@spec_spy.version} built to #{@spec_spy.gem_file}\n"
482
+ exp +=
483
+ "#{@spec_spy.name} #{@spec_spy.version} built to "\
484
+ "#{@spec_spy.gem_file}\n"
483
485
  assert_equal exp, @stdout.read
484
486
 
485
487
  ENV["DEBUG"] = nil
@@ -487,7 +489,9 @@ class GGem::CLI
487
489
 
488
490
  should "handle cmd errors when run" do
489
491
  err_msg = Factory.string
490
- Assert.stub(@spec_spy, :run_build_cmd){ raise GGem::Gemspec::CmdError, err_msg }
492
+ Assert.stub(@spec_spy, :run_build_cmd) do
493
+ raise GGem::Gemspec::CmdError, err_msg
494
+ end
491
495
 
492
496
  assert_raises(CommandExitError){ subject.run([], @stdout, @stderr) }
493
497
  assert_equal "#{err_msg}\n", @stderr.read
@@ -500,7 +504,9 @@ class GGem::CLI
500
504
  desc "InstallCommand"
501
505
  setup do
502
506
  @build_spy = nil
503
- Assert.stub(BuildCommand, :new){ |*args| @build_spy = CommandSpy.new(*args) }
507
+ Assert.stub(BuildCommand, :new) do |*args|
508
+ @build_spy = CommandSpy.new(*args)
509
+ end
504
510
 
505
511
  @command_class = InstallCommand
506
512
  @cmd = @command_class.new
@@ -527,7 +533,8 @@ class GGem::CLI
527
533
  assert @build_spy
528
534
  end
529
535
 
530
- should "run the build command and call the spec's run install cmds when run" do
536
+ should "run the build command and call the spec's run install cmds when "\
537
+ "run" do
531
538
  ENV["DEBUG"] = [nil, "1"].sample
532
539
  subject.run(@argv, @stdout, @stderr)
533
540
 
@@ -544,7 +551,9 @@ class GGem::CLI
544
551
 
545
552
  should "handle cmd errors when run" do
546
553
  err_msg = Factory.string
547
- Assert.stub(@spec_spy, :run_install_cmd){ raise GGem::Gemspec::CmdError, err_msg }
554
+ Assert.stub(@spec_spy, :run_install_cmd) do
555
+ raise GGem::Gemspec::CmdError, err_msg
556
+ end
548
557
 
549
558
  assert_raises(CommandExitError){ subject.run(@argv, @stdout, @stderr) }
550
559
  assert_equal "#{err_msg}\n", @stderr.read
@@ -557,7 +566,9 @@ class GGem::CLI
557
566
  desc "PushCommand"
558
567
  setup do
559
568
  @build_spy = nil
560
- Assert.stub(BuildCommand, :new){ |*args| @build_spy = CommandSpy.new(*args) }
569
+ Assert.stub(BuildCommand, :new) do |*args|
570
+ @build_spy = CommandSpy.new(*args)
571
+ end
561
572
 
562
573
  @command_class = PushCommand
563
574
  @cmd = @command_class.new
@@ -602,7 +613,9 @@ class GGem::CLI
602
613
 
603
614
  should "handle cmd errors when run" do
604
615
  err_msg = Factory.string
605
- Assert.stub(@spec_spy, :run_push_cmd){ raise GGem::Gemspec::CmdError, err_msg }
616
+ Assert.stub(@spec_spy, :run_push_cmd) do
617
+ raise GGem::Gemspec::CmdError, err_msg
618
+ end
606
619
 
607
620
  assert_raises(CommandExitError){ subject.run(@argv, @stdout, @stderr) }
608
621
  assert_equal "#{err_msg}\n", @stderr.read
@@ -715,7 +728,9 @@ class GGem::CLI
715
728
 
716
729
  should "remove the version tag on push errors" do
717
730
  err_msg = Factory.string
718
- Assert.stub(@repo_spy, :run_push_cmd){ raise GGem::GitRepo::CmdError, err_msg }
731
+ Assert.stub(@repo_spy, :run_push_cmd) do
732
+ raise GGem::GitRepo::CmdError, err_msg
733
+ end
719
734
 
720
735
  assert_raises(CommandExitError){ subject.run([], @stdout, @stderr) }
721
736
  assert_equal "#{err_msg}\n", @stderr.read
@@ -725,9 +740,13 @@ class GGem::CLI
725
740
  end
726
741
 
727
742
  should "handle tag removal cmd errors when run" do
728
- Assert.stub(@repo_spy, :run_push_cmd){ raise GGem::GitRepo::CmdError, Factory.string }
743
+ Assert.stub(@repo_spy, :run_push_cmd) do
744
+ raise GGem::GitRepo::CmdError, Factory.string
745
+ end
729
746
  err_msg = Factory.string
730
- Assert.stub(@repo_spy, :run_rm_tag_cmd){ raise GGem::GitRepo::CmdError, err_msg }
747
+ Assert.stub(@repo_spy, :run_rm_tag_cmd) do
748
+ raise GGem::GitRepo::CmdError, err_msg
749
+ end
731
750
 
732
751
  assert_raises(CommandExitError){ subject.run([], @stdout, @stderr) }
733
752
  assert_equal "#{err_msg}\n", @stderr.read
@@ -743,7 +762,9 @@ class GGem::CLI
743
762
  Assert.stub(TagCommand, :new){ |*args| @tag_spy = CommandSpy.new(*args) }
744
763
 
745
764
  @push_spy = nil
746
- Assert.stub(PushCommand, :new){ |*args| @push_spy = CommandSpy.new(*args) }
765
+ Assert.stub(PushCommand, :new) do |*args|
766
+ @push_spy = CommandSpy.new(*args)
767
+ end
747
768
 
748
769
  @command_class = ReleaseCommand
749
770
  @cmd = @command_class.new
@@ -755,8 +776,9 @@ class GGem::CLI
755
776
  end
756
777
 
757
778
  should "know its summary" do
758
- exp = "Tag #{@spec_spy.version_tag} and push built #{@spec_spy.gem_file_name} to " \
759
- "#{@spec_spy.push_host}"
779
+ exp =
780
+ "Tag #{@spec_spy.version_tag} and push built "\
781
+ "#{@spec_spy.gem_file_name} to #{@spec_spy.push_host}"
760
782
  assert_equal exp, subject.summary
761
783
  end
762
784
 
@@ -935,7 +957,8 @@ class GGem::CLI
935
957
 
936
958
  class GemspecSpy
937
959
  attr_reader :name, :version, :version_tag, :push_host
938
- attr_reader :run_build_cmd_called, :run_install_cmd_called, :run_push_cmd_called
960
+ attr_reader :run_build_cmd_called, :run_install_cmd_called
961
+ attr_reader :run_push_cmd_called
939
962
 
940
963
  def initialize(root_path)
941
964
  @root = Pathname.new(File.expand_path(root_path))
@@ -950,15 +973,15 @@ class GGem::CLI
950
973
  end
951
974
 
952
975
  def path
953
- @root.join("#{self.name}.gemspec")
976
+ @root.join("#{name}.gemspec")
954
977
  end
955
978
 
956
979
  def gem_file_name
957
- "#{self.name}-#{self.version}.gem"
980
+ "#{name}-#{version}.gem"
958
981
  end
959
982
 
960
983
  def gem_file
961
- File.join(GGem::Gemspec::BUILD_TO_DIRNAME, self.gem_file_name)
984
+ File.join(GGem::Gemspec::BUILD_TO_DIRNAME, gem_file_name)
962
985
  end
963
986
 
964
987
  def run_build_cmd
@@ -980,8 +1003,10 @@ class GGem::CLI
980
1003
  class GitRepoSpy
981
1004
  attr_reader :path
982
1005
  attr_reader :run_init_cmd_called
983
- attr_reader :run_validate_clean_cmd_called, :run_validate_committed_cmd_called
984
- attr_reader :run_add_version_tag_cmd_called_with, :run_rm_tag_cmd_called_with
1006
+ attr_reader :run_validate_clean_cmd_called
1007
+ attr_reader :run_validate_committed_cmd_called
1008
+ attr_reader :run_add_version_tag_cmd_called_with
1009
+ attr_reader :run_rm_tag_cmd_called_with
985
1010
  attr_reader :run_push_cmd_called
986
1011
 
987
1012
  def initialize(path)