OSDN Git Service

ruby-1.9.1-rc1
[splhack/AndroidRuby.git] / lib / ruby-1.9.1-rc1 / test / rubygems / test_gem_commands_stale_command.rb
1 require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
2 require 'rubygems/commands/stale_command'
3
4 class TestGemCommandsStaleCommand < RubyGemTestCase
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_gem 'foo_bar' do |gem|
14       gem.files = files
15     end
16     bar_baz = quick_gem 'bar_baz' do |gem|
17       gem.files = files
18     end
19
20     files.each do |file|
21       filename = bar_baz.full_gem_path + "/#{file}"
22       FileUtils.mkdir_p(File.dirname(filename))
23       FileUtils.touch(filename, :mtime => Time.now)
24
25       filename = foo_bar.full_gem_path + "/#{file}"
26       FileUtils.mkdir_p(File.dirname(filename))
27       FileUtils.touch(filename, :mtime => Time.now - 86400)
28     end
29
30     use_ui @ui do
31       @cmd.execute
32     end
33     lines = @ui.output.split("\n")
34     assert_equal("#{foo_bar.name}-#{foo_bar.version}", lines[0].split.first)
35     assert_equal("#{bar_baz.name}-#{bar_baz.version}", lines[1].split.first)
36   end
37
38 end