2016-02-01 07:43:26 -05:00
|
|
|
# frozen_string_literal: true
|
2011-01-28 18:46:47 -05:00
|
|
|
require 'rubygems/test_case'
|
2010-02-21 21:52:35 -05:00
|
|
|
require "rubygems/requirement"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2011-01-28 18:46:47 -05:00
|
|
|
class TestGemRequirement < Gem::TestCase
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
def test_concat
|
|
|
|
r = req '>= 1'
|
|
|
|
|
|
|
|
r.concat ['< 2']
|
|
|
|
|
|
|
|
assert_equal [['>=', v(1)], ['<', v(2)]], r.requirements
|
|
|
|
end
|
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
def test_equals2
|
2010-02-21 21:52:35 -05:00
|
|
|
r = req "= 1.2"
|
|
|
|
assert_equal r, r.dup
|
|
|
|
assert_equal r.dup, r
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
refute_requirement_equal "= 1.2", "= 1.3"
|
|
|
|
refute_requirement_equal "= 1.3", "= 1.2"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
refute_equal Object.new, req("= 1.2")
|
|
|
|
refute_equal req("= 1.2"), Object.new
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
def test_initialize
|
|
|
|
assert_requirement_equal "= 2", "2"
|
|
|
|
assert_requirement_equal "= 2", ["2"]
|
|
|
|
assert_requirement_equal "= 2", v(2)
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_requirement_equal "2.0", "2"
|
|
|
|
assert_requirement_equal ["= 2", ">= 2"], [">= 2", "= 2"]
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2017-10-07 21:32:18 -04:00
|
|
|
def test_create
|
|
|
|
assert_equal req("= 1"), Gem::Requirement.create("= 1")
|
|
|
|
assert_equal req(">= 1.2", "<= 1.3"), Gem::Requirement.create([">= 1.2", "<= 1.3"])
|
|
|
|
assert_equal req(">= 1.2", "<= 1.3"), Gem::Requirement.create(">= 1.2", "<= 1.3")
|
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_empty_requirements_is_none
|
|
|
|
r = Gem::Requirement.new
|
|
|
|
assert_equal true, r.none?
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_explicit_default_is_none
|
|
|
|
r = Gem::Requirement.new ">= 0"
|
|
|
|
assert_equal true, r.none?
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_basic_non_none
|
|
|
|
r = Gem::Requirement.new "= 1"
|
|
|
|
assert_equal false, r.none?
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
def test_for_lockfile
|
|
|
|
assert_equal ' (~> 1.0)', req('~> 1.0').for_lockfile
|
|
|
|
|
2013-12-07 20:22:39 -05:00
|
|
|
assert_equal ' (~> 1.0, >= 1.0.1)', req('>= 1.0.1', '~> 1.0').for_lockfile
|
|
|
|
|
|
|
|
duped = req '= 1.0'
|
|
|
|
duped.requirements << ['=', v('1.0')]
|
|
|
|
|
|
|
|
assert_equal ' (= 1.0)', duped.for_lockfile
|
|
|
|
|
2013-11-10 12:51:40 -05:00
|
|
|
assert_nil Gem::Requirement.default.for_lockfile
|
|
|
|
end
|
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
def test_parse
|
2010-02-21 21:52:35 -05:00
|
|
|
assert_equal ['=', Gem::Version.new(1)], Gem::Requirement.parse(' 1')
|
|
|
|
assert_equal ['=', Gem::Version.new(1)], Gem::Requirement.parse('= 1')
|
|
|
|
assert_equal ['>', Gem::Version.new(1)], Gem::Requirement.parse('> 1')
|
|
|
|
assert_equal ['=', Gem::Version.new(1)], Gem::Requirement.parse("=\n1")
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_equal ['=', Gem::Version.new(1)], Gem::Requirement.parse('1.0')
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
assert_equal ['=', Gem::Version.new(2)],
|
|
|
|
Gem::Requirement.parse(Gem::Version.new('2'))
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
def test_parse_bad
|
2013-09-24 20:53:19 -04:00
|
|
|
[
|
|
|
|
nil,
|
|
|
|
'',
|
|
|
|
'! 1',
|
|
|
|
'= junk',
|
|
|
|
'1..2',
|
|
|
|
].each do |bad|
|
|
|
|
e = assert_raises Gem::Requirement::BadRequirementError do
|
|
|
|
Gem::Requirement.parse bad
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_equal "Illformed requirement [#{bad.inspect}]", e.message
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
assert_equal Gem::Requirement::BadRequirementError.superclass, ArgumentError
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
def test_prerelease_eh
|
|
|
|
r = req '= 1'
|
|
|
|
|
|
|
|
refute r.prerelease?
|
|
|
|
|
|
|
|
r = req '= 1.a'
|
|
|
|
|
|
|
|
assert r.prerelease?
|
|
|
|
|
|
|
|
r = req '> 1.a', '< 2'
|
|
|
|
|
|
|
|
assert r.prerelease?
|
|
|
|
end
|
|
|
|
|
2007-11-10 02:48:56 -05:00
|
|
|
def test_satisfied_by_eh_bang_equal
|
2010-02-21 21:52:35 -05:00
|
|
|
r = req '!= 1.2'
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
assert_satisfied_by "1.1", r
|
|
|
|
refute_satisfied_by "1.2", r
|
|
|
|
assert_satisfied_by "1.3", r
|
2012-11-29 01:52:18 -05:00
|
|
|
|
|
|
|
assert_raises ArgumentError do
|
|
|
|
assert_satisfied_by nil, r
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_satisfied_by_eh_blank
|
2010-02-21 21:52:35 -05:00
|
|
|
r = req "1.2"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
refute_satisfied_by "1.1", r
|
|
|
|
assert_satisfied_by "1.2", r
|
|
|
|
refute_satisfied_by "1.3", r
|
2012-11-29 01:52:18 -05:00
|
|
|
|
|
|
|
assert_raises ArgumentError do
|
|
|
|
assert_satisfied_by nil, r
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_satisfied_by_eh_equal
|
2010-02-21 21:52:35 -05:00
|
|
|
r = req "= 1.2"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
refute_satisfied_by "1.1", r
|
|
|
|
assert_satisfied_by "1.2", r
|
|
|
|
refute_satisfied_by "1.3", r
|
2012-11-29 01:52:18 -05:00
|
|
|
|
|
|
|
assert_raises ArgumentError do
|
|
|
|
assert_satisfied_by nil, r
|
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_satisfied_by_eh_gt
|
2010-02-21 21:52:35 -05:00
|
|
|
r = req "> 1.2"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
refute_satisfied_by "1.1", r
|
|
|
|
refute_satisfied_by "1.2", r
|
|
|
|
assert_satisfied_by "1.3", r
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
assert_raises ArgumentError do
|
2010-02-21 21:52:35 -05:00
|
|
|
r.satisfied_by? nil
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_satisfied_by_eh_gte
|
2010-02-21 21:52:35 -05:00
|
|
|
r = req ">= 1.2"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
refute_satisfied_by "1.1", r
|
|
|
|
assert_satisfied_by "1.2", r
|
|
|
|
assert_satisfied_by "1.3", r
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
assert_raises ArgumentError do
|
2010-02-21 21:52:35 -05:00
|
|
|
r.satisfied_by? nil
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_satisfied_by_eh_list
|
2010-02-21 21:52:35 -05:00
|
|
|
r = req "> 1.1", "< 1.3"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
refute_satisfied_by "1.1", r
|
|
|
|
assert_satisfied_by "1.2", r
|
|
|
|
refute_satisfied_by "1.3", r
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
assert_raises ArgumentError do
|
2010-02-21 21:52:35 -05:00
|
|
|
r.satisfied_by? nil
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_satisfied_by_eh_lt
|
2010-02-21 21:52:35 -05:00
|
|
|
r = req "< 1.2"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
assert_satisfied_by "1.1", r
|
|
|
|
refute_satisfied_by "1.2", r
|
|
|
|
refute_satisfied_by "1.3", r
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
assert_raises ArgumentError do
|
2010-02-21 21:52:35 -05:00
|
|
|
r.satisfied_by? nil
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_satisfied_by_eh_lte
|
2010-02-21 21:52:35 -05:00
|
|
|
r = req "<= 1.2"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
assert_satisfied_by "1.1", r
|
|
|
|
assert_satisfied_by "1.2", r
|
|
|
|
refute_satisfied_by "1.3", r
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
assert_raises ArgumentError do
|
2010-02-21 21:52:35 -05:00
|
|
|
r.satisfied_by? nil
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_satisfied_by_eh_tilde_gt
|
2010-02-21 21:52:35 -05:00
|
|
|
r = req "~> 1.2"
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
refute_satisfied_by "1.1", r
|
|
|
|
assert_satisfied_by "1.2", r
|
|
|
|
assert_satisfied_by "1.3", r
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
assert_raises ArgumentError do
|
2010-02-21 21:52:35 -05:00
|
|
|
r.satisfied_by? nil
|
2007-11-10 02:48:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-13 23:30:02 -04:00
|
|
|
def test_satisfied_by_eh_tilde_gt_v0
|
|
|
|
r = req "~> 0.0.1"
|
|
|
|
|
|
|
|
refute_satisfied_by "0.1.1", r
|
|
|
|
assert_satisfied_by "0.0.2", r
|
|
|
|
assert_satisfied_by "0.0.1", r
|
|
|
|
end
|
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
def test_satisfied_by_eh_good
|
|
|
|
assert_satisfied_by "0.2.33", "= 0.2.33"
|
|
|
|
assert_satisfied_by "0.2.34", "> 0.2.33"
|
|
|
|
assert_satisfied_by "1.0", "= 1.0"
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_satisfied_by "1.0.0", "= 1.0"
|
|
|
|
assert_satisfied_by "1.0", "= 1.0.0"
|
2010-02-21 21:52:35 -05:00
|
|
|
assert_satisfied_by "1.0", "1.0"
|
|
|
|
assert_satisfied_by "1.8.2", "> 1.8.0"
|
|
|
|
assert_satisfied_by "1.112", "> 1.111"
|
|
|
|
assert_satisfied_by "0.2", "> 0.0.0"
|
|
|
|
assert_satisfied_by "0.0.0.0.0.2", "> 0.0.0"
|
|
|
|
assert_satisfied_by "0.0.1.0", "> 0.0.0.1"
|
|
|
|
assert_satisfied_by "10.3.2", "> 9.3.2"
|
|
|
|
assert_satisfied_by "1.0.0.0", "= 1.0"
|
|
|
|
assert_satisfied_by "10.3.2", "!= 9.3.4"
|
|
|
|
assert_satisfied_by "10.3.2", "> 9.3.2"
|
|
|
|
assert_satisfied_by "10.3.2", "> 9.3.2"
|
|
|
|
assert_satisfied_by " 9.3.2", ">= 9.3.2"
|
|
|
|
assert_satisfied_by "9.3.2 ", ">= 9.3.2"
|
|
|
|
assert_satisfied_by "", "= 0"
|
|
|
|
assert_satisfied_by "", "< 0.1"
|
|
|
|
assert_satisfied_by " ", "< 0.1 "
|
|
|
|
assert_satisfied_by "", " < 0.1"
|
|
|
|
assert_satisfied_by " ", "> 0.a "
|
|
|
|
assert_satisfied_by "", " > 0.a"
|
|
|
|
assert_satisfied_by "3.1", "< 3.2.rc1"
|
2011-03-09 17:32:29 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
assert_satisfied_by "3.2.0", "> 3.2.0.rc1"
|
|
|
|
assert_satisfied_by "3.2.0.rc2", "> 3.2.0.rc1"
|
2011-03-09 17:32:29 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
assert_satisfied_by "3.0.rc2", "< 3.0"
|
|
|
|
assert_satisfied_by "3.0.rc2", "< 3.0.0"
|
|
|
|
assert_satisfied_by "3.0.rc2", "< 3.0.1"
|
2011-03-09 17:32:29 -05:00
|
|
|
|
|
|
|
assert_satisfied_by "3.0.rc2", "> 0"
|
2010-02-21 21:52:35 -05:00
|
|
|
end
|
2007-11-10 02:48:56 -05:00
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
def test_illformed_requirements
|
|
|
|
[ ">>> 1.3.5", "> blah" ].each do |rq|
|
2012-11-29 01:52:18 -05:00
|
|
|
assert_raises Gem::Requirement::BadRequirementError, "req [#{rq}] should fail" do
|
2010-02-21 21:52:35 -05:00
|
|
|
Gem::Requirement.new rq
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-11-29 01:52:18 -05:00
|
|
|
def test_satisfied_by_eh_non_versions
|
|
|
|
assert_raises ArgumentError do
|
|
|
|
req(">= 0").satisfied_by? Object.new
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_raises ArgumentError do
|
|
|
|
req(">= 0").satisfied_by? Gem::Requirement.default
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
def test_satisfied_by_eh_boxed
|
|
|
|
refute_satisfied_by "1.3", "~> 1.4"
|
|
|
|
assert_satisfied_by "1.4", "~> 1.4"
|
|
|
|
assert_satisfied_by "1.5", "~> 1.4"
|
|
|
|
refute_satisfied_by "2.0", "~> 1.4"
|
|
|
|
|
|
|
|
refute_satisfied_by "1.3", "~> 1.4.4"
|
|
|
|
refute_satisfied_by "1.4", "~> 1.4.4"
|
|
|
|
assert_satisfied_by "1.4.4", "~> 1.4.4"
|
|
|
|
assert_satisfied_by "1.4.5", "~> 1.4.4"
|
|
|
|
refute_satisfied_by "1.5", "~> 1.4.4"
|
|
|
|
refute_satisfied_by "2.0", "~> 1.4.4"
|
|
|
|
|
|
|
|
refute_satisfied_by "1.1.pre", "~> 1.0.0"
|
2011-01-18 19:08:49 -05:00
|
|
|
refute_satisfied_by "1.1.pre", "~> 1.1"
|
2010-02-21 21:52:35 -05:00
|
|
|
refute_satisfied_by "2.0.a", "~> 1.0"
|
2011-01-18 19:08:49 -05:00
|
|
|
refute_satisfied_by "2.0.a", "~> 2.0"
|
2014-09-13 23:30:02 -04:00
|
|
|
|
|
|
|
refute_satisfied_by "0.9", "~> 1"
|
|
|
|
assert_satisfied_by "1.0", "~> 1"
|
|
|
|
assert_satisfied_by "1.1", "~> 1"
|
|
|
|
refute_satisfied_by "2.0", "~> 1"
|
2010-02-21 21:52:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_satisfied_by_eh_multiple
|
|
|
|
req = [">= 1.4", "<= 1.6", "!= 1.5"]
|
|
|
|
|
|
|
|
refute_satisfied_by "1.3", req
|
|
|
|
assert_satisfied_by "1.4", req
|
|
|
|
refute_satisfied_by "1.5", req
|
|
|
|
assert_satisfied_by "1.6", req
|
|
|
|
refute_satisfied_by "1.7", req
|
|
|
|
refute_satisfied_by "2.0", req
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_satisfied_by_boxed
|
|
|
|
refute_satisfied_by "1.3", "~> 1.4"
|
|
|
|
assert_satisfied_by "1.4", "~> 1.4"
|
2018-05-30 09:01:35 -04:00
|
|
|
assert_satisfied_by "1.4.0", "~> 1.4"
|
2010-02-21 21:52:35 -05:00
|
|
|
assert_satisfied_by "1.5", "~> 1.4"
|
|
|
|
refute_satisfied_by "2.0", "~> 1.4"
|
|
|
|
|
|
|
|
refute_satisfied_by "1.3", "~> 1.4.4"
|
|
|
|
refute_satisfied_by "1.4", "~> 1.4.4"
|
|
|
|
assert_satisfied_by "1.4.4", "~> 1.4.4"
|
|
|
|
assert_satisfied_by "1.4.5", "~> 1.4.4"
|
|
|
|
refute_satisfied_by "1.5", "~> 1.4.4"
|
|
|
|
refute_satisfied_by "2.0", "~> 1.4.4"
|
|
|
|
end
|
|
|
|
|
2018-05-30 09:01:35 -04:00
|
|
|
def test_satisfied_by_explicitly_bounded
|
|
|
|
req = [">= 1.4.4", "< 1.5"]
|
|
|
|
|
|
|
|
assert_satisfied_by "1.4.5", req
|
|
|
|
assert_satisfied_by "1.5.0.rc1", req
|
|
|
|
refute_satisfied_by "1.5.0", req
|
|
|
|
|
|
|
|
req = [">= 1.4.4", "< 1.5.a"]
|
|
|
|
|
|
|
|
assert_satisfied_by "1.4.5", req
|
|
|
|
refute_satisfied_by "1.5.0.rc1", req
|
|
|
|
refute_satisfied_by "1.5.0", req
|
|
|
|
end
|
|
|
|
|
2011-05-31 23:45:05 -04:00
|
|
|
def test_specific
|
|
|
|
refute req('> 1') .specific?
|
|
|
|
refute req('>= 1').specific?
|
|
|
|
|
|
|
|
assert req('!= 1').specific?
|
|
|
|
assert req('< 1') .specific?
|
|
|
|
assert req('<= 1').specific?
|
|
|
|
assert req('= 1') .specific?
|
|
|
|
assert req('~> 1').specific?
|
|
|
|
|
|
|
|
assert req('> 1', '> 2').specific? # GIGO
|
|
|
|
end
|
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
def test_bad
|
|
|
|
refute_satisfied_by "", "> 0.1"
|
|
|
|
refute_satisfied_by "1.2.3", "!= 1.2.3"
|
|
|
|
refute_satisfied_by "1.2.003.0.0", "!= 1.02.3"
|
|
|
|
refute_satisfied_by "4.5.6", "< 1.2.3"
|
|
|
|
refute_satisfied_by "1.0", "> 1.1"
|
|
|
|
refute_satisfied_by "", "= 0.1"
|
|
|
|
refute_satisfied_by "1.1.1", "> 1.1.1"
|
|
|
|
refute_satisfied_by "1.2", "= 1.1"
|
|
|
|
refute_satisfied_by "1.40", "= 1.1"
|
|
|
|
refute_satisfied_by "1.3", "= 1.40"
|
|
|
|
refute_satisfied_by "9.3.3", "<= 9.3.2"
|
|
|
|
refute_satisfied_by "9.3.1", ">= 9.3.2"
|
|
|
|
refute_satisfied_by "9.3.03", "<= 9.3.2"
|
|
|
|
refute_satisfied_by "1.0.0.1", "= 1.0"
|
|
|
|
end
|
|
|
|
|
2015-02-05 08:42:45 -05:00
|
|
|
def test_hash_with_multiple_versions
|
|
|
|
r1 = req('1.0', '2.0')
|
|
|
|
r2 = req('2.0', '1.0')
|
|
|
|
assert_equal r1.hash, r2.hash
|
|
|
|
|
|
|
|
r1 = req('1.0', '2.0').tap { |r| r.concat(['3.0']) }
|
|
|
|
r2 = req('3.0', '1.0').tap { |r| r.concat(['2.0']) }
|
|
|
|
assert_equal r1.hash, r2.hash
|
|
|
|
end
|
|
|
|
|
2010-02-21 21:52:35 -05:00
|
|
|
# Assert that two requirements are equal. Handles Gem::Requirements,
|
|
|
|
# strings, arrays, numbers, and versions.
|
|
|
|
|
|
|
|
def assert_requirement_equal expected, actual
|
|
|
|
assert_equal req(expected), req(actual)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Assert that +version+ satisfies +requirement+.
|
|
|
|
|
|
|
|
def assert_satisfied_by version, requirement
|
|
|
|
assert req(requirement).satisfied_by?(v(version)),
|
|
|
|
"#{requirement} is satisfied by #{version}"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Refute the assumption that two requirements are equal.
|
|
|
|
|
|
|
|
def refute_requirement_equal unexpected, actual
|
|
|
|
refute_equal req(unexpected), req(actual)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Refute the assumption that +version+ satisfies +requirement+.
|
|
|
|
|
|
|
|
def refute_satisfied_by version, requirement
|
|
|
|
refute req(requirement).satisfied_by?(v(version)),
|
|
|
|
"#{requirement} is not satisfied by #{version}"
|
|
|
|
end
|
|
|
|
end
|