2 require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3 require 'rubygems/commands/specification_command'
5 class TestGemCommandsSpecificationCommand < RubyGemTestCase
10 @cmd = Gem::Commands::SpecificationCommand.new
15 Gem.source_index.add_spec foo
17 @cmd.options[:args] = %w[foo]
23 assert_match %r|Gem::Specification|, @ui.output
24 assert_match %r|name: foo|, @ui.output
25 assert_equal '', @ui.error
29 foo1 = quick_gem 'foo', '0.0.1'
30 foo2 = quick_gem 'foo', '0.0.2'
32 @cmd.options[:args] = %w[foo]
33 @cmd.options[:all] = true
39 assert_match %r|Gem::Specification|, @ui.output
40 assert_match %r|name: foo|, @ui.output
41 assert_match %r|version: 0.0.1|, @ui.output
42 assert_match %r|version: 0.0.2|, @ui.output
43 assert_equal '', @ui.error
46 def test_execute_bad_name
47 @cmd.options[:args] = %w[foo]
49 assert_raise MockGemUi::TermError do
55 assert_equal '', @ui.output
56 assert_equal "ERROR: Unknown gem 'foo'\n", @ui.error
59 def test_execute_exact_match
61 foo_bar = quick_gem 'foo_bar'
63 @cmd.options[:args] = %w[foo]
69 assert_match %r|Gem::Specification|, @ui.output
70 assert_match %r|name: foo|, @ui.output
71 assert_equal '', @ui.error
74 def test_execute_remote
77 util_setup_source_info_cache foo
79 FileUtils.rm File.join(@gemhome, 'specifications',
80 "#{foo.full_name}.gemspec")
82 @cmd.options[:args] = %w[foo]
83 @cmd.options[:domain] = :remote
89 assert_match %r|\A--- !ruby/object:Gem::Specification|, @ui.output
90 assert_match %r|name: foo|, @ui.output