diff options
author | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-01 03:45:05 +0000 |
---|---|---|
committer | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-01 03:45:05 +0000 |
commit | d22130922e7842226d38d59680e4bbb48a28a5f0 (patch) | |
tree | 39594d3a14641dd5488a99a5e633239296fa5742 /test/rubygems/test_gem_commands_unpack_command.rb | |
parent | 4752539e3f3e563d559732c52424206bd6f12dbd (diff) | |
download | ruby-d22130922e7842226d38d59680e4bbb48a28a5f0.tar.gz |
Import rubygems 1.8.5 (released @ 137c80f)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_commands_unpack_command.rb')
-rw-r--r-- | test/rubygems/test_gem_commands_unpack_command.rb | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/test/rubygems/test_gem_commands_unpack_command.rb b/test/rubygems/test_gem_commands_unpack_command.rb index 8764a4017b..3f072277f1 100644 --- a/test/rubygems/test_gem_commands_unpack_command.rb +++ b/test/rubygems/test_gem_commands_unpack_command.rb @@ -21,20 +21,20 @@ class TestGemCommandsUnpackCommand < Gem::TestCase util_make_gems assert_equal( - @cmd.find_in_cache(@a1.file_name), - Gem.cache_gem(@a1.file_name, @gemhome), + @cmd.find_in_cache(File.basename @a1.cache_file), + @a1.cache_file, 'found a-1.gem in the cache' ) end def test_get_path - util_make_gems util_setup_fake_fetcher + util_clear_gems util_setup_spec_fetcher @a1 a1_data = nil - open Gem.cache_gem(@a1.file_name, @gemhome), 'rb' do |fp| + open @a1.cache_file, 'rb' do |fp| a1_data = fp.read end @@ -44,15 +44,15 @@ class TestGemCommandsUnpackCommand < Gem::TestCase dep = Gem::Dependency.new(@a1.name, @a1.version) assert_equal( @cmd.get_path(dep), - Gem.cache_gem(@a1.file_name, @gemhome), + @a1.cache_file, 'fetches a-1 and returns the cache path' ) - FileUtils.rm Gem.cache_gem(@a1.file_name, @gemhome) + FileUtils.rm @a1.cache_file assert_equal( @cmd.get_path(dep), - Gem.cache_gem(@a1.file_name, @gemhome), + @a1.cache_file, 'when removed from cache, refetches a-1' ) end @@ -73,16 +73,14 @@ class TestGemCommandsUnpackCommand < Gem::TestCase end def test_execute_gem_path - util_make_gems - util_setup_spec_fetcher util_setup_fake_fetcher + util_setup_spec_fetcher Gem.clear_paths gemhome2 = File.join @tempdir, 'gemhome2' - Gem.send :set_paths, [gemhome2, @gemhome].join(File::PATH_SEPARATOR) - Gem.send :set_home, gemhome2 + Gem.paths = { "GEM_PATH" => [gemhome2, @gemhome], "GEM_HOME" => gemhome2 } @cmd.options[:args] = %w[a] @@ -96,15 +94,14 @@ class TestGemCommandsUnpackCommand < Gem::TestCase end def test_execute_gem_path_missing - util_make_gems + util_setup_fake_fetcher util_setup_spec_fetcher Gem.clear_paths gemhome2 = File.join @tempdir, 'gemhome2' - Gem.send :set_paths, [gemhome2, @gemhome].join(File::PATH_SEPARATOR) - Gem.send :set_home, gemhome2 + Gem.paths = { "GEM_PATH" => [gemhome2, @gemhome], "GEM_HOME" => gemhome2 } @cmd.options[:args] = %w[z] @@ -123,7 +120,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase util_clear_gems a2_data = nil - open Gem.cache_gem(@a2.file_name, @gemhome), 'rb' do |fp| + open @a2.cache_file, 'rb' do |fp| a2_data = fp.read end @@ -142,10 +139,28 @@ class TestGemCommandsUnpackCommand < Gem::TestCase assert File.exist?(File.join(@tempdir, 'a-2')), 'a should be unpacked' end + def test_execute_spec + util_make_gems + + @cmd.options[:args] = %w[a b] + @cmd.options[:spec] = true + + use_ui @ui do + Dir.chdir @tempdir do + @cmd.execute + end + end + + assert File.exist?(File.join(@tempdir, 'a-3.a.gemspec')) + assert File.exist?(File.join(@tempdir, 'b-2.gemspec')) + end + def test_execute_sudo + skip 'Cannot perform this test on windows (chmod)' if win_platform? + util_make_gems - File.chmod 0555, @gemhome + FileUtils.chmod 0555, @gemhome @cmd.options[:args] = %w[b] @@ -157,7 +172,7 @@ class TestGemCommandsUnpackCommand < Gem::TestCase assert File.exist?(File.join(@tempdir, 'b-2')), 'b should be unpacked' ensure - File.chmod 0755, @gemhome + FileUtils.chmod 0755, @gemhome end def test_execute_with_target_option @@ -203,5 +218,13 @@ class TestGemCommandsUnpackCommand < Gem::TestCase assert File.exist?(File.join(@tempdir, foo_spec.full_name)) end + def test_handle_options_metadata + refute @cmd.options[:spec] + + @cmd.send :handle_options, %w[--spec a] + + assert @cmd.options[:spec] + end + end |