diff options
| author | Jack Nagel | 2013-01-12 21:19:11 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-01-12 21:20:46 -0600 |
| commit | 900a5fec2d5341db275bccdcd70936690a0e778c (patch) | |
| tree | a4cbe7427ffc1c0cd6b94abca6f673f19d3e9a74 /Library | |
| parent | 09b77a7785708ad7c1d72ea4b5169118aaa79268 (diff) | |
| download | brew-900a5fec2d5341db275bccdcd70936690a0e778c.tar.bz2 | |
Beef up deps tests
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/test/test_dependencies.rb | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/Library/Homebrew/test/test_dependencies.rb b/Library/Homebrew/test/test_dependencies.rb index a09dee7cb..ebfd8ac01 100644 --- a/Library/Homebrew/test/test_dependencies.rb +++ b/Library/Homebrew/test/test_dependencies.rb @@ -2,15 +2,15 @@ require 'testing_env' require 'test/testball' require 'dependencies' -class DependencyCollector +module DependencyCollectorTestExtension def find_dependency(name) deps.find { |dep| dep.name == name } end end -class DependencyTests < Test::Unit::TestCase +class DependencyCollectorTests < Test::Unit::TestCase def setup - @d = DependencyCollector.new + @d = DependencyCollector.new.extend(DependencyCollectorTestExtension) end def test_dependency_creation @@ -34,3 +34,58 @@ class DependencyTests < Test::Unit::TestCase assert_empty @d.find_dependency('foo').tags 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 |
