summaryrefslogtreecommitdiff
path: root/jni/ruby/test/rubygems/test_gem_resolver_dependency_request.rb
blob: 0665883971fb4acfd86d9d6adaa3e4fd3a0f1db4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
require 'rubygems/test_case'

class TestGemResolverDependencyRequest < Gem::TestCase

  def setup
    super

    @DR = Gem::Resolver::DependencyRequest
  end

  def test_development_eh
    a_dep = dep 'a', '>= 1'

    a_dep_req = @DR.new a_dep, nil

    refute a_dep_req.development?

    b_dep = dep 'b', '>= 1', :development

    b_dep_req = @DR.new b_dep, nil

    assert b_dep_req.development?
  end

  def test_match_eh
    spec = util_spec 'a', 1
    dependency = dep 'a', '>= 1'

    dr = @DR.new dependency, nil

    assert dr.match? spec
  end

  def test_match_eh_prerelease
    spec = util_spec 'a', '1.a'

    a_dep = dep 'a', '>= 1'
    a_dr = @DR.new a_dep, nil

    refute a_dr.match? spec

    a_pre_dep = dep 'a', '>= 1.a'
    a_pre_dr = @DR.new a_pre_dep, nil

    assert a_pre_dr.match? spec
  end

  def test_match_eh_prerelease_allow_prerelease
    spec = util_spec 'a', '2.a'

    a_dep = dep 'a', '>= 1'
    a_dr = @DR.new a_dep, nil

    assert a_dr.match? spec, true
  end

  def test_matches_spec_eh
    spec = util_spec 'a', 1
    dependency = dep 'a', '>= 1'

    dr = @DR.new dependency, nil

    assert dr.matches_spec? spec
  end

  def test_matches_spec_eh_prerelease
    spec = util_spec 'a', '1.a'

    dependency = dep 'a', '>= 0'
    dr = @DR.new dependency, nil

    assert dr.matches_spec? spec
  end

  def test_requirement
    dependency = dep 'a', '>= 1'

    dr = @DR.new dependency, nil

    assert_equal dependency, dr.dependency
  end

end