From fe4f39dcee409c8b9b164f20d86024ae02a792b2 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sun, 13 Jan 2013 20:05:09 -0600 Subject: Split up dependency test coverage The DependencyCollector tests are really integration tests, while the rest are closer to real unit tests. Split them up so that the tests can be run in isolation on a per-class basis. --- Library/Homebrew/test/test_dependency.rb | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Library/Homebrew/test/test_dependency.rb (limited to 'Library/Homebrew/test/test_dependency.rb') diff --git a/Library/Homebrew/test/test_dependency.rb b/Library/Homebrew/test/test_dependency.rb new file mode 100644 index 000000000..a043c1bd5 --- /dev/null +++ b/Library/Homebrew/test/test_dependency.rb @@ -0,0 +1,51 @@ +require 'testing_env' +require 'dependencies' + +class DependableTests < Test::Unit::TestCase + def setup + @tags = ["foo", "bar", :build] + @dep = Struct.new(:tags).new(@tags).extend(Dependable) + end + + def test_options + assert_equal %w{--foo --bar}.sort, @dep.options.sort + end + + def test_interrogation + assert @dep.build? + assert !@dep.optional? + assert !@dep.recommended? + end +end + +class DependencyTests < Test::Unit::TestCase + def test_accepts_single_tag + dep = Dependency.new("foo", "bar") + assert_equal %w{bar}, dep.tags + end + + def test_accepts_multiple_tags + dep = Dependency.new("foo", %w{bar baz}) + assert_equal %w{bar baz}.sort, dep.tags.sort + end + + def test_preserves_symbol_tags + dep = Dependency.new("foo", :build) + assert_equal [:build], dep.tags + end + + def test_accepts_symbol_and_string_tags + dep = Dependency.new("foo", [:build, "bar"]) + assert_equal [:build, "bar"], dep.tags + end + + def test_equality + foo1 = Dependency.new("foo") + foo2 = Dependency.new("foo") + bar = Dependency.new("bar") + assert_equal foo1, foo2 + assert foo1.eql?(foo2) + assert_not_equal foo1, bar + assert !foo1.eql?(bar) + end +end -- cgit v1.2.3