aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/test_exceptions.rb19
-rw-r--r--Library/Homebrew/test/test_formulary.rb10
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