2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2011-01-28 18:46:47 -05:00
|
|
|
require 'rubygems/test_case'
|
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
|
|
|
|
|
|
|
|
assert_path_exists b.gem_dir
|
|
|
|
refute_path_exists b.spec_file
|
|
|
|
|
|
|
|
Gem.use_paths @gemhome
|
|
|
|
|
|
|
|
capture_io do
|
|
|
|
use_ui @ui do
|
|
|
|
@cmd.doctor
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
refute_path_exists b.gem_dir
|
|
|
|
refute_path_exists b.spec_file
|
|
|
|
end
|
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|