1require 'rubygems/test_case' 2require 'rubygems/commands/stale_command' 3 4class TestGemCommandsStaleCommand < Gem::TestCase 5 6 def setup 7 super 8 @cmd = Gem::Commands::StaleCommand.new 9 end 10 11 def test_execute_sorts 12 files = %w[lib/foo_bar.rb Rakefile] 13 foo_bar = quick_spec 'foo_bar' do |gem| 14 gem.files = files 15 end 16 17 bar_baz = quick_spec 'bar_baz' do |gem| 18 gem.files = files 19 end 20 21 files.each do |file| 22 filename = File.join(bar_baz.full_gem_path, file) 23 FileUtils.mkdir_p File.dirname filename 24 FileUtils.touch(filename, :mtime => Time.now) 25 26 filename = File.join(foo_bar.full_gem_path, file) 27 FileUtils.mkdir_p File.dirname filename 28 FileUtils.touch(filename, :mtime => Time.now - 86400) 29 end 30 31 use_ui @ui do 32 @cmd.execute 33 end 34 35 lines = @ui.output.split("\n") 36 assert_equal("#{foo_bar.name}-#{foo_bar.version}", lines[0].split.first) 37 assert_equal("#{bar_baz.name}-#{bar_baz.version}", lines[1].split.first) 38 end 39 40end 41