2 require File.join(File.expand_path(File.dirname(__FILE__)), 'gemutilities')
3 require 'rubygems/command'
4 require 'rubygems/version_option'
6 class TestGemVersionOption < RubyGemTestCase
11 @cmd = Gem::Command.new 'dummy', 'dummy'
12 @cmd.extend Gem::VersionOption
15 def test_add_platform_option
16 @cmd.add_platform_option
18 assert @cmd.handles?(%w[--platform x86-darwin])
21 def test_add_version_option
22 @cmd.add_version_option
24 assert @cmd.handles?(%w[--version >1])
27 def test_platform_option
28 @cmd.add_platform_option
30 @cmd.handle_options %w[--platform x86-freebsd6 --platform x86-freebsd7]
34 Gem::Platform.new('x86-freebsd6'),
35 Gem::Platform.new('x86-freebsd7'),
38 assert_equal expected, Gem.platforms
41 def test_platform_option_ruby
42 @cmd.add_platform_option
44 @cmd.handle_options %w[--platform ruby]
50 assert_equal expected, Gem.platforms
53 def test_platform_option_twice
54 @cmd.add_platform_option
56 @cmd.handle_options %w[--platform x86-freebsd6 --platform x86-freebsd-6]
60 Gem::Platform.new('x86-freebsd6'),
63 assert_equal expected, Gem.platforms
66 def test_version_option
67 @cmd.add_version_option
69 @cmd.handle_options %w[--version >1]
71 expected = { :version => Gem::Requirement.new('> 1'), :args => [] }
73 assert_equal expected, @cmd.options