Beef up deps tests
This commit is contained in:
parent
09b77a7785
commit
900a5fec2d
@ -2,15 +2,15 @@ require 'testing_env'
|
|||||||
require 'test/testball'
|
require 'test/testball'
|
||||||
require 'dependencies'
|
require 'dependencies'
|
||||||
|
|
||||||
class DependencyCollector
|
module DependencyCollectorTestExtension
|
||||||
def find_dependency(name)
|
def find_dependency(name)
|
||||||
deps.find { |dep| dep.name == name }
|
deps.find { |dep| dep.name == name }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class DependencyTests < Test::Unit::TestCase
|
class DependencyCollectorTests < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
@d = DependencyCollector.new
|
@d = DependencyCollector.new.extend(DependencyCollectorTestExtension)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dependency_creation
|
def test_dependency_creation
|
||||||
@ -34,3 +34,58 @@ class DependencyTests < Test::Unit::TestCase
|
|||||||
assert_empty @d.find_dependency('foo').tags
|
assert_empty @d.find_dependency('foo').tags
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class DependenciesTests < Test::Unit::TestCase
|
||||||
|
def setup
|
||||||
|
@deps = Dependencies.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_shovel_returns_self
|
||||||
|
assert_same @deps, (@deps << Dependency.new("foo"))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_no_duplicate_deps
|
||||||
|
@deps << Dependency.new("foo")
|
||||||
|
@deps << Dependency.new("foo", :build)
|
||||||
|
@deps << Dependency.new("foo", :build)
|
||||||
|
assert_equal 1, @deps.count
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_preserves_order
|
||||||
|
hash = { 0 => "foo", 1 => "bar", 2 => "baz" }
|
||||||
|
@deps << Dependency.new(hash[0])
|
||||||
|
@deps << Dependency.new(hash[1])
|
||||||
|
@deps << Dependency.new(hash[2])
|
||||||
|
@deps.each_with_index do |dep, idx|
|
||||||
|
assert_equal hash[idx], dep.name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_repetition
|
||||||
|
@deps << Dependency.new("foo")
|
||||||
|
@deps << Dependency.new("bar")
|
||||||
|
assert_equal %q{foo, bar}, @deps*', '
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_to_ary
|
||||||
|
assert_instance_of Array, @deps.to_ary
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class DependableTests < Test::Unit::TestCase
|
||||||
|
def setup
|
||||||
|
@tags = ["foo", "bar", :build]
|
||||||
|
@deps = Struct.new(:tags).new(@tags)
|
||||||
|
@deps.extend(Dependable)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_options
|
||||||
|
assert_equal %w{--foo --bar}.sort, @deps.options.sort
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_interrogation
|
||||||
|
assert @deps.build?
|
||||||
|
assert !@deps.optional?
|
||||||
|
assert !@deps.recommended?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user