From 73fc703f7cbb2e6dfd50897d26b37fe8e76064e3 Mon Sep 17 00:00:00 2001 From: drbrain Date: Sat, 30 Nov 2013 23:27:52 +0000 Subject: * lib/rubygems: Update to RubyGems master 66e5c39. Notable changes: Implement gem.deps.rb (Gemfile) .lock support Fixed `gem uninstall` for a relative directory in GEM_HOME. * test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rubygems/test_gem_source_lock.rb | 107 ++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 test/rubygems/test_gem_source_lock.rb (limited to 'test/rubygems/test_gem_source_lock.rb') diff --git a/test/rubygems/test_gem_source_lock.rb b/test/rubygems/test_gem_source_lock.rb new file mode 100644 index 0000000000..d114dccbb7 --- /dev/null +++ b/test/rubygems/test_gem_source_lock.rb @@ -0,0 +1,107 @@ +require 'rubygems/test_case' + +class TestGemSourceLock < Gem::TestCase + + def test_fetch_spec + spec_fetcher do |fetcher| + fetcher.spec 'a', 1 + end + + name_tuple = Gem::NameTuple.new 'a', v(1), 'ruby' + + remote = Gem::Source.new @gem_repo + lock = Gem::Source::Lock.new remote + + spec = lock.fetch_spec name_tuple + + assert_equal 'a-1', spec.full_name + end + + def test_equals2 + git = Gem::Source::Git.new 'a', 'git/a', 'master', false + g_lock = Gem::Source::Lock.new git + + installed = Gem::Source::Installed.new + i_lock = Gem::Source::Lock.new installed + + assert_equal g_lock, g_lock + refute_equal g_lock, i_lock + refute_equal g_lock, Object.new + end + + def test_spaceship + git = Gem::Source::Git.new 'a', 'git/a', 'master', false + g_lock = Gem::Source::Lock.new git + + installed = Gem::Source::Installed.new + i_lock = Gem::Source::Lock.new installed + + vendor = Gem::Source::Vendor.new 'vendor/a' + v_lock = Gem::Source::Lock.new vendor + + assert_equal( 0, g_lock.<=>(g_lock), 'g_lock <=> g_lock') + assert_equal( 0, i_lock.<=>(i_lock), 'i_lock <=> i_lock') + assert_equal( 0, v_lock.<=>(v_lock), 'v_lock <=> v_lock') + + assert_equal(-1, g_lock.<=>(i_lock), 'g_lock <=> i_lock') + assert_equal( 1, i_lock.<=>(g_lock), 'i_lock <=> g_lock') + + assert_equal(-1, g_lock.<=>(v_lock), 'g_lock <=> v_lock') + assert_equal( 1, v_lock.<=>(g_lock), 'v_lock <=> g_lock') + + assert_equal(-1, i_lock.<=>(v_lock), 'i_lock <=> v_lock') + assert_equal( 1, v_lock.<=>(i_lock), 'i_lock <=> v_lock') + end + + def test_spaceship_git + git = Gem::Source::Git.new 'a', 'git/a', 'master', false + lock = Gem::Source::Lock.new git + + assert_equal( 1, lock.<=>(git), 'lock <=> git') + assert_equal(-1, git .<=>(lock), 'git <=> lock') + end + + def test_spaceship_installed + installed = Gem::Source::Installed.new + lock = Gem::Source::Lock.new installed + + assert_equal( 1, lock. <=>(installed), 'lock <=> installed') + assert_equal(-1, installed.<=>(lock), 'installed <=> lock') + end + + def test_spaceship_local + local = Gem::Source::Local.new + lock = Gem::Source::Lock.new local # nonsense + + assert_equal( 1, lock. <=>(local), 'lock <=> local') + assert_equal(-1, local.<=>(lock), 'local <=> lock') + end + + def test_spaceship_remote + remote = Gem::Source.new @gem_repo + lock = Gem::Source::Lock.new remote + + assert_equal( 1, lock. <=>(remote), 'lock <=> remote') + assert_equal(-1, remote.<=>(lock), 'remote <=> lock') + end + + def test_spaceship_specific_file + _, gem = util_gem 'a', 1 + + specific = Gem::Source::SpecificFile.new gem + lock = Gem::Source::Lock.new specific # nonsense + + assert_equal( 1, lock .<=>(specific), 'lock <=> specific') + assert_equal(-1, specific.<=>(lock), 'specific <=> lock') + end + + def test_spaceship_vendor + vendor = Gem::Source::Vendor.new 'vendor/a' + lock = Gem::Source::Lock.new vendor + + assert_equal( 1, lock. <=>(vendor), 'lock <=> vendor') + assert_equal(-1, vendor.<=>(lock), 'vendor <=> lock') + end + +end + -- cgit v1.2.3