2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2021-06-01 23:32:47 -04:00
|
|
|
require_relative 'helper'
|
2007-11-10 02:48:56 -05:00
|
|
|
require 'rubygems/commands/check_command'
|
|
|
|
|
2011-01-28 18:46:47 -05:00
|
|
|
class TestGemCommandsCheckCommand < Gem::TestCase
|
2007-11-10 02:48:56 -05:00
|
|
|
def setup
|
|
|
|
super
|
|
|
|
|
|
|
|
@cmd = Gem::Commands::CheckCommand.new
|
|
|
|
end
|
|
|
|
|
2018-11-21 05:20:47 -05:00
|
|
|
def gem(name)
|
2012-12-22 19:35:09 -05:00
|
|
|
spec = quick_gem name do |gem|
|
|
|
|
gem.files = %W[lib/#{name}.rb Rakefile]
|
|
|
|
end
|
|
|
|
|
|
|
|
write_file File.join(*%W[gems #{spec.full_name} lib #{name}.rb])
|
|
|
|
write_file File.join(*%W[gems #{spec.full_name} Rakefile])
|
|
|
|
|
|
|
|
spec
|
|
|
|
end
|
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
def test_initialize
|
|
|
|
assert_equal "check", @cmd.command
|
|
|
|
assert_equal "gem check", @cmd.program_name
|
|
|
|
assert_match(/Check/, @cmd.summary)
|
|
|
|
end
|
|
|
|
|
2012-12-22 19:35:09 -05:00
|
|
|
def test_handle_options
|
|
|
|
@cmd.handle_options %w[--no-alien --no-gems --doctor --dry-run]
|
|
|
|
|
|
|
|
assert @cmd.options[:doctor]
|
|
|
|
refute @cmd.options[:alien]
|
|
|
|
assert @cmd.options[:dry_run]
|
|
|
|
refute @cmd.options[:gems]
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_handle_options_defaults
|
|
|
|
@cmd.handle_options []
|
|
|
|
|
|
|
|
assert @cmd.options[:alien]
|
|
|
|
assert @cmd.options[:gems]
|
|
|
|
refute @cmd.options[:doctor]
|
|
|
|
refute @cmd.options[:dry_run]
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_doctor
|
2013-01-04 02:31:57 -05:00
|
|
|
gem 'a'
|
2012-12-22 19:35:09 -05:00
|
|
|
b = gem 'b'
|
|
|
|
|
|
|
|
FileUtils.rm b.spec_file
|
|
|
|
|
2020-05-25 08:05:45 -04:00
|
|
|
assert_path_exist b.gem_dir
|
|
|
|
assert_path_not_exist b.spec_file
|
2012-12-22 19:35:09 -05:00
|
|
|
|
|
|
|
Gem.use_paths @gemhome
|
|
|
|
|
2019-06-29 07:16:49 -04:00
|
|
|
capture_output do
|
2012-12-22 19:35:09 -05:00
|
|
|
use_ui @ui do
|
|
|
|
@cmd.doctor
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-05-25 08:05:45 -04:00
|
|
|
assert_path_not_exist b.gem_dir
|
|
|
|
assert_path_not_exist b.spec_file
|
2012-12-22 19:35:09 -05:00
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|