diff options
| author | Martin Afanasjew | 2016-04-16 22:08:04 +0200 |
|---|---|---|
| committer | Martin Afanasjew | 2016-04-17 21:16:01 +0200 |
| commit | 144d86f73315f59d65234ace69880bb9d3a90acb (patch) | |
| tree | 6698a03cf68cd92255f820d206c8acc940637c57 /Library | |
| parent | 94a627d7aafb59107a0d94766585205a416114f0 (diff) | |
| download | brew-144d86f73315f59d65234ace69880bb9d3a90acb.tar.bz2 | |
tests: test FormulaClassUnavailableError
Closes #101.
Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/test/test_exceptions.rb | 19 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_formulary.rb | 10 |
2 files changed, 29 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_exceptions.rb b/Library/Homebrew/test/test_exceptions.rb index e49201736..88744a255 100644 --- a/Library/Homebrew/test/test_exceptions.rb +++ b/Library/Homebrew/test/test_exceptions.rb @@ -37,6 +37,25 @@ class ExceptionsTest < Homebrew::TestCase TapFormulaUnavailableError.new(t, "foo").to_s end + def test_formula_class_unavailable_error + mod = Module.new + mod.module_eval <<-EOS.undent + class Bar < Requirement; end + class Baz < Formula; end + EOS + + assert_match "Expected to find class Foo, but found no classes.", + FormulaClassUnavailableError.new("foo", "foo.rb", "Foo", []).to_s + + list = [mod.const_get(:Bar)] + assert_match "Expected to find class Foo, but only found: Bar (not derived from Formula!).", + FormulaClassUnavailableError.new("foo", "foo.rb", "Foo", list).to_s + + list = [mod.const_get(:Baz)] + assert_match "Expected to find class Foo, but only found: Baz.", + FormulaClassUnavailableError.new("foo", "foo.rb", "Foo", list).to_s + end + def test_tap_unavailable_error assert_equal "No available tap foo.\n", TapUnavailableError.new("foo").to_s end diff --git a/Library/Homebrew/test/test_formulary.rb b/Library/Homebrew/test/test_formulary.rb index 738012c17..d8f57a90b 100644 --- a/Library/Homebrew/test/test_formulary.rb +++ b/Library/Homebrew/test/test_formulary.rb @@ -54,6 +54,16 @@ class FormularyFactoryTest < Homebrew::TestCase assert_raises(FormulaUnavailableError) { Formulary.factory("not_existed_formula") } end + def test_formula_class_unavailable_error + name = "giraffe" + path = CoreTap.new.formula_dir/"#{name}.rb" + path.write "class Wrong#{Formulary.class_s(name)} < Formula\nend\n" + + assert_raises(FormulaClassUnavailableError) { Formulary.factory(name) } + ensure + path.unlink + end + def test_factory_from_path assert_kind_of Formula, Formulary.factory(@path) end |
