1require 'rubygems/test_case' 2require 'rubygems/commands/check_command' 3 4class TestGemCommandsCheckCommand < Gem::TestCase 5 6 def setup 7 super 8 9 @cmd = Gem::Commands::CheckCommand.new 10 end 11 12 def gem name 13 spec = quick_gem name do |gem| 14 gem.files = %W[lib/#{name}.rb Rakefile] 15 end 16 17 write_file File.join(*%W[gems #{spec.full_name} lib #{name}.rb]) 18 write_file File.join(*%W[gems #{spec.full_name} Rakefile]) 19 20 spec 21 end 22 23 def test_initialize 24 assert_equal "check", @cmd.command 25 assert_equal "gem check", @cmd.program_name 26 assert_match(/Check/, @cmd.summary) 27 end 28 29 def test_handle_options 30 @cmd.handle_options %w[--no-alien --no-gems --doctor --dry-run] 31 32 assert @cmd.options[:doctor] 33 refute @cmd.options[:alien] 34 assert @cmd.options[:dry_run] 35 refute @cmd.options[:gems] 36 end 37 38 def test_handle_options_defaults 39 @cmd.handle_options [] 40 41 assert @cmd.options[:alien] 42 assert @cmd.options[:gems] 43 refute @cmd.options[:doctor] 44 refute @cmd.options[:dry_run] 45 end 46 47 def test_doctor 48 gem 'a' 49 b = gem 'b' 50 51 FileUtils.rm b.spec_file 52 53 assert_path_exists b.gem_dir 54 refute_path_exists b.spec_file 55 56 Gem.use_paths @gemhome 57 58 capture_io do 59 use_ui @ui do 60 @cmd.doctor 61 end 62 end 63 64 refute_path_exists b.gem_dir 65 refute_path_exists b.spec_file 66 end 67 68end 69