2 require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3 require 'rubygems/commands/dependency_command'
5 class TestGemCommandsDependencyCommand < RubyGemTestCase
10 @cmd = Gem::Commands::DependencyCommand.new
11 @cmd.options[:domain] = :local
15 quick_gem 'foo' do |gem|
16 gem.add_dependency 'bar', '> 1'
19 @cmd.options[:args] = %w[foo]
25 assert_equal "Gem foo-2\n bar (> 1)\n\n", @ui.output
26 assert_equal '', @ui.error
29 def test_execute_no_match
30 @cmd.options[:args] = %w[foo]
32 assert_raise MockGemUi::TermError do
38 assert_equal "No match found for foo (>= 0)\n", @ui.output
39 assert_equal '', @ui.error
42 def test_execute_pipe_format
43 quick_gem 'foo' do |gem|
44 gem.add_dependency 'bar', '> 1'
47 @cmd.options[:args] = %w[foo]
48 @cmd.options[:pipe_format] = true
54 assert_equal "bar --version '> 1'\n", @ui.output
55 assert_equal '', @ui.error
58 def test_execute_reverse
59 quick_gem 'foo' do |gem|
60 gem.add_dependency 'bar', '> 1'
63 quick_gem 'baz' do |gem|
64 gem.add_dependency 'foo'
67 @cmd.options[:args] = %w[foo]
68 @cmd.options[:reverse_dependencies] = true
82 assert_equal expected, @ui.output
83 assert_equal '', @ui.error
86 def test_execute_remote
87 foo = quick_gem 'foo' do |gem|
88 gem.add_dependency 'bar', '> 1'
91 util_setup_source_info_cache foo
93 FileUtils.rm File.join(@gemhome, 'specifications',
94 "#{foo.full_name}.gemspec")
96 @cmd.options[:args] = %w[foo]
97 @cmd.options[:domain] = :remote
103 assert_equal "Gem foo-2\n bar (> 1)\n\n", @ui.output
104 assert_equal '', @ui.error