2013-07-09 19:21:36 -04:00
|
|
|
require 'rubygems/test_case'
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
class TestGemResolverConflict < Gem::TestCase
|
|
|
|
|
|
|
|
def test_self_compatibility
|
|
|
|
assert_same Gem::Resolver::Conflict, Gem::Resolver::DependencyConflict
|
|
|
|
end
|
2013-07-09 19:21:36 -04:00
|
|
|
|
|
|
|
def test_explanation
|
|
|
|
root =
|
|
|
|
dependency_request dep('net-ssh', '>= 2.0.13'), 'rye', '0.9.8'
|
2013-07-09 19:41:44 -04:00
|
|
|
child =
|
2013-07-09 19:21:36 -04:00
|
|
|
dependency_request dep('net-ssh', '>= 2.6.5'), 'net-ssh', '2.2.2', root
|
|
|
|
|
2013-11-21 18:27:30 -05:00
|
|
|
dep = Gem::Resolver::DependencyRequest.new dep('net-ssh', '>= 2.0.13'), nil
|
|
|
|
|
|
|
|
spec = quick_spec 'net-ssh', '2.2.2'
|
|
|
|
active =
|
|
|
|
Gem::Resolver::ActivationRequest.new spec, dep
|
|
|
|
|
2013-07-09 19:21:36 -04:00
|
|
|
conflict =
|
2013-11-21 18:27:30 -05:00
|
|
|
Gem::Resolver::Conflict.new child, active
|
2013-07-09 19:21:36 -04:00
|
|
|
|
|
|
|
expected = <<-EXPECTED
|
2013-11-21 18:27:30 -05:00
|
|
|
Activated net-ssh-2.2.2 via:
|
|
|
|
net-ssh-2.2.2 (>= 2.0.13)
|
|
|
|
instead of (>= 2.6.5) via:
|
|
|
|
net-ssh-2.2.2 (>= 2.0.13), rye-0.9.8 (= 0.9.8)
|
2013-07-09 19:21:36 -04:00
|
|
|
EXPECTED
|
|
|
|
|
|
|
|
assert_equal expected, conflict.explanation
|
|
|
|
end
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
def test_explanation_user_request
|
2013-11-18 19:34:13 -05:00
|
|
|
@DR = Gem::Resolver
|
2013-11-10 12:51:40 -05:00
|
|
|
|
2013-11-11 19:16:41 -05:00
|
|
|
spec = util_spec 'a', 2
|
2013-11-10 12:51:40 -05:00
|
|
|
|
|
|
|
a1_req = @DR::DependencyRequest.new dep('a', '= 1'), nil
|
|
|
|
a2_req = @DR::DependencyRequest.new dep('a', '= 2'), nil
|
|
|
|
|
|
|
|
activated = @DR::ActivationRequest.new spec, a2_req
|
|
|
|
|
2013-11-18 19:34:13 -05:00
|
|
|
conflict = @DR::Conflict.new a1_req, activated
|
2013-11-10 12:51:40 -05:00
|
|
|
|
|
|
|
expected = <<-EXPECTED
|
2013-11-21 18:27:30 -05:00
|
|
|
Activated a-2 via:
|
|
|
|
a-2 (= 2)
|
|
|
|
instead of (= 1) via:
|
2013-11-10 12:51:40 -05:00
|
|
|
user request (gem command or Gemfile)
|
|
|
|
EXPECTED
|
|
|
|
|
|
|
|
assert_equal expected, conflict.explanation
|
|
|
|
end
|
|
|
|
|
2013-07-09 19:21:36 -04:00
|
|
|
def test_request_path
|
|
|
|
root =
|
|
|
|
dependency_request dep('net-ssh', '>= 2.0.13'), 'rye', '0.9.8'
|
2013-11-21 18:27:30 -05:00
|
|
|
|
2013-07-09 19:41:44 -04:00
|
|
|
child =
|
2013-11-21 18:27:30 -05:00
|
|
|
dependency_request dep('other', '>= 1.0'), 'net-ssh', '2.2.2', root
|
2013-07-09 19:21:36 -04:00
|
|
|
|
|
|
|
conflict =
|
2013-11-21 18:27:30 -05:00
|
|
|
Gem::Resolver::Conflict.new nil, nil
|
|
|
|
|
|
|
|
expected = [
|
|
|
|
'net-ssh-2.2.2 (>= 2.0.13)',
|
|
|
|
'rye-0.9.8 (= 0.9.8)'
|
|
|
|
]
|
2013-07-09 19:21:36 -04:00
|
|
|
|
2013-11-21 18:27:30 -05:00
|
|
|
assert_equal expected, conflict.request_path(child.requester)
|
2013-07-09 19:21:36 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|