Skip to content
Snippets Groups Projects
Commit 0b2c6e87 authored by Jack Nagel's avatar Jack Nagel
Browse files

Implement equality for Dependencies collections

parent 257a2206
No related branches found
No related tags found
No related merge requests found
......@@ -46,4 +46,12 @@ class Dependencies
def default
build + required + recommended
end
attr_reader :deps
protected :deps
def ==(other)
deps == other.deps
end
alias_method :eql?, :==
end
......@@ -59,4 +59,22 @@ class DependenciesTests < Test::Unit::TestCase
assert_equal [qux], @deps.recommended
assert_equal [foo, baz, quux, qux].sort_by(&:name), @deps.default.sort_by(&:name)
end
def test_equality
a = Dependencies.new
b = Dependencies.new
dep = Dependency.new("foo")
a << dep
b << dep
assert_equal a, b
assert a.eql?(b)
b << Dependency.new("bar", [:optional])
assert_not_equal a, b
assert !a.eql?(b)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment