Skip to content

Commit

Permalink
Add Resolver::DependencyRequest#match?
Browse files Browse the repository at this point in the history
This new method only matches prerelease versions when this is a
prerelease dependency.

Part of #853
  • Loading branch information
drbrain committed May 21, 2014
1 parent 959a01c commit 599c9ba
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/rubygems/resolver/dependency_request.rb
Expand Up @@ -42,7 +42,19 @@ def development?
end

##
# Does this dependency request match +spec+
# Does this dependency request match +spec+?
#
# NOTE: #match? only matches prerelease versions when #dependency is a
# prerelease dependency.

def match? spec
@dependency.match? spec
end

##
# Does this dependency request match +spec+?
#
# NOTE: #matches_spec? matches prerelease versions. See also #match?

def matches_spec?(spec)
@dependency.matches_spec? spec
Expand Down
23 changes: 23 additions & 0 deletions test/rubygems/test_gem_resolver_dependency_request.rb
Expand Up @@ -22,6 +22,29 @@ def test_development_eh
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_requirement
dependency = dep 'a', '>= 1'

Expand Down

0 comments on commit 599c9ba

Please sign in to comment.