aboutsummaryrefslogtreecommitdiffstats
path: root/test/rubygems/test_gem_source_git.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-19 00:34:13 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-19 00:34:13 +0000
commita7fa4d5d9aab150ad4b0c3f3217fe444df69f527 (patch)
tree88ab96d22f7228b556337aa7c34042d4fd279394 /test/rubygems/test_gem_source_git.rb
parente7ec3dad907f2c77f17faddb40a98b2ef4523222 (diff)
downloadruby-a7fa4d5d9aab150ad4b0c3f3217fe444df69f527.tar.gz
* lib/rubygems: Update to RubyGems master 6a3d9f9. Changes include:
Compatibly renamed Gem::DependencyResolver to Gem::Resolver. Added support for git gems in gem.deps.rb and Gemfile. Fixed resolver bugs. * test/rubygems: ditto. * lib/rubygems/LICENSE.txt: Updated to license from RubyGems trunk. [ruby-trunk - Bug #9086] * lib/rubygems/commands/which_command.rb: RubyGems now indicates failure when any file is missing. [ruby-trunk - Bug #9004] * lib/rubygems/ext/builder: Extensions are now installed into the extension install directory and the first directory in the require path from the gem. This allows backwards compatibility with msgpack and other gems that calculate full require paths. [ruby-trunk - Bug #9106] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rubygems/test_gem_source_git.rb')
-rw-r--r--test/rubygems/test_gem_source_git.rb153
1 files changed, 153 insertions, 0 deletions
diff --git a/test/rubygems/test_gem_source_git.rb b/test/rubygems/test_gem_source_git.rb
new file mode 100644
index 0000000000..78c415a9d3
--- /dev/null
+++ b/test/rubygems/test_gem_source_git.rb
@@ -0,0 +1,153 @@
+require 'rubygems/test_case'
+require 'rubygems/source'
+
+class TestGemSourceGit < Gem::TestCase
+
+ def setup
+ super
+
+ @name, @version, @repository, @head = git_gem
+
+ @hash = Digest::SHA1.hexdigest @repository
+
+ @source = Gem::Source::Git.new @name, @repository, 'master', false
+ end
+
+ def test_checkout
+ @source.checkout
+
+ assert_path_exists File.join @source.install_dir, 'a.gemspec'
+ end
+
+ def test_checkout_submodules
+ source = Gem::Source::Git.new @name, @repository, 'master', true
+
+ git_gem 'b'
+
+ Dir.chdir 'git/a' do
+ system @git, 'submodule', '--quiet', 'add', File.expand_path('../b'), 'b'
+ system @git, 'commit', '--quiet', '-m', 'add submodule b'
+ end
+
+ source.checkout
+
+ assert_path_exists File.join source.install_dir, 'a.gemspec'
+ assert_path_exists File.join source.install_dir, 'b/b.gemspec'
+ end
+
+ def test_cache
+ assert @source.cache
+
+ assert_path_exists @source.repo_cache_dir
+
+ Dir.chdir @source.repo_cache_dir do
+ assert_equal @head, Gem::Util.popen(@git, 'rev-parse', 'master').strip
+ end
+ end
+
+ def test_dir_shortref
+ @source.cache
+
+ assert_equal @head[0..11], @source.dir_shortref
+ end
+
+ def test_equals2
+ assert_equal @source, @source
+
+ assert_equal @source, @source.dup
+
+ source =
+ Gem::Source::Git.new @source.name, @source.repository, 'other', false
+
+ refute_equal @source, source
+
+ source =
+ Gem::Source::Git.new @source.name, 'repo/other', @source.reference, false
+
+ refute_equal @source, source
+
+ source =
+ Gem::Source::Git.new 'b', @source.repository, @source.reference, false
+
+ refute_equal @source, source
+
+ source =
+ Gem::Source::Git.new @source.name, @source.repository, @source.reference,
+ true
+
+ refute_equal @source, source
+ end
+
+ def test_load_spec
+ spec = @source.load_spec @name
+
+ assert_equal "#{@name}-#{@version}", spec.full_name
+ end
+
+ def test_install_dir
+ @source.cache
+
+ expected = File.join Gem.dir, 'bundler', 'gems', "a-#{@head[0..11]}"
+
+ assert_equal expected, @source.install_dir
+ end
+
+ def test_repo_cache_dir
+ expected =
+ File.join Gem.dir, 'cache', 'bundler', 'git', "a-#{@hash}"
+
+ assert_equal expected, @source.repo_cache_dir
+ end
+
+ def test_rev_parse
+ @source.cache
+
+ assert_equal @head, @source.rev_parse
+
+ Dir.chdir @repository do
+ system @git, 'checkout', '--quiet', '-b', 'other'
+ end
+
+ master_head = @head
+
+ git_gem 'a', 2
+
+ source = Gem::Source::Git.new @name, @repository, 'other', false
+
+ source.cache
+
+ refute_equal master_head, source.rev_parse
+ end
+
+ def test_spaceship
+ git = Gem::Source::Git.new 'a', 'git/a', 'master', false
+ remote = Gem::Source.new @gem_repo
+ installed = Gem::Source::Installed.new
+
+ assert_equal( 0, git. <=>(git), 'git <=> git')
+
+ assert_equal( 1, git. <=>(remote), 'git <=> remote')
+ assert_equal(-1, remote. <=>(git), 'remote <=> git')
+
+ assert_equal( 1, installed.<=>(git), 'installed <=> git')
+ assert_equal(-1, git. <=>(installed), 'git <=> installed')
+ end
+
+ def test_uri_hash
+ assert_equal @hash, @source.uri_hash
+
+ source =
+ Gem::Source::Git.new 'a', 'http://git@example/repo.git', 'master', false
+
+ assert_equal '291c4caac7feba8bb64c297987028acb3dde6cfe',
+ source.uri_hash
+
+ source =
+ Gem::Source::Git.new 'a', 'HTTP://git@EXAMPLE/repo.git', 'master', false
+
+ assert_equal '291c4caac7feba8bb64c297987028acb3dde6cfe',
+ source.uri_hash
+ end
+
+end
+