aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaptiste Fontaine2015-07-20 21:46:05 +0200
committerBaptiste Fontaine2015-07-25 00:00:30 +0200
commitca1f5dc713313485b13512571cd222c4e89730a3 (patch)
treee70a35c03fd0b59ae211ae043f00bbf0779a4456
parenta675aae553949706c54c8868a941373d73909260 (diff)
downloadbrew-ca1f5dc713313485b13512571cd222c4e89730a3.tar.bz2
more unit tests
Closes Homebrew/homebrew#42096. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
-rw-r--r--Library/Homebrew/test/test_caveats.rb27
-rw-r--r--Library/Homebrew/test/test_dependencies.rb14
-rw-r--r--Library/Homebrew/test/test_formula.rb24
-rw-r--r--Library/Homebrew/test/test_options.rb15
-rw-r--r--Library/Homebrew/test/test_version_subclasses.rb6
5 files changed, 86 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_caveats.rb b/Library/Homebrew/test/test_caveats.rb
new file mode 100644
index 000000000..5708ebc03
--- /dev/null
+++ b/Library/Homebrew/test/test_caveats.rb
@@ -0,0 +1,27 @@
+require 'testing_env'
+
+class CaveatsTests < Homebrew::TestCase
+ def setup
+ @f = formula { url "foo-1.0" }
+ @c = Caveats.new @f
+ end
+
+ def test_f
+ assert_equal @f, @c.f
+ end
+
+ def test_empty?
+ assert @c.empty?
+
+ f = formula do
+ url "foo-1.0"
+
+ def caveats
+ "something"
+ end
+ end
+ c = Caveats.new f
+
+ refute c.empty?
+ end
+end
diff --git a/Library/Homebrew/test/test_dependencies.rb b/Library/Homebrew/test/test_dependencies.rb
index b587cd12a..7e4812ff7 100644
--- a/Library/Homebrew/test/test_dependencies.rb
+++ b/Library/Homebrew/test/test_dependencies.rb
@@ -71,6 +71,20 @@ class DependenciesTests < Homebrew::TestCase
refute_equal a, b
refute_eql a, b
end
+
+ def test_empty
+ a = Dependencies.new
+ assert a.empty?
+ a << Dependency.new("foo")
+ refute a.empty?
+ end
+
+ def test_inspect
+ a = Dependencies.new
+ assert_equal "#<Dependencies: []>", a.inspect
+ a << Dependency.new("foo")
+ assert_equal "#<Dependencies: [#<Dependency: \"foo\" []>]>", a.inspect
+ end
end
class RequirementsTests < Homebrew::TestCase
diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb
index 47f807333..11886ab05 100644
--- a/Library/Homebrew/test/test_formula.rb
+++ b/Library/Homebrew/test/test_formula.rb
@@ -257,4 +257,28 @@ class FormulaTests < Homebrew::TestCase
assert f.option_defined?("bar")
assert f.option_defined?("baz")
end
+
+ def test_desc
+ f = formula do
+ desc "a formula"
+ url "foo-1.0"
+ end
+
+ assert_equal "a formula", f.desc
+ end
+
+ def test_post_install_defined
+ f1 = formula do
+ url "foo-1.0"
+
+ def post_install;end
+ end
+
+ f2 = formula do
+ url "foo-1.0"
+ end
+
+ assert f1.post_install_defined?
+ refute f2.post_install_defined?
+ end
end
diff --git a/Library/Homebrew/test/test_options.rb b/Library/Homebrew/test/test_options.rb
index e9d3d0836..604727961 100644
--- a/Library/Homebrew/test/test_options.rb
+++ b/Library/Homebrew/test/test_options.rb
@@ -23,6 +23,10 @@ class OptionTests < Homebrew::TestCase
assert_empty @option.description
assert_equal "foo", Option.new("foo", "foo").description
end
+
+ def test_inspect
+ assert_equal "#<Option: \"--foo\">", @option.inspect
+ end
end
class DeprecatedOptionTests < Homebrew::TestCase
@@ -121,10 +125,21 @@ class OptionsTests < Homebrew::TestCase
assert_equal [foo, bar, baz].sort, (@options | options).sort
end
+ def test_times
+ @options << Option.new("aa") << Option.new("bb") << Option.new("cc")
+ assert_equal %w[--aa --bb --cc], (@options * "XX").split("XX").sort
+ end
+
def test_create_with_array
array = %w{--foo --bar}
option1 = Option.new("foo")
option2 = Option.new("bar")
assert_equal [option1, option2].sort, Options.create(array).sort
end
+
+ def test_inspect
+ assert_equal "#<Options: []>", @options.inspect
+ @options << Option.new("foo")
+ assert_equal "#<Options: [#<Option: \"--foo\">]>", @options.inspect
+ end
end
diff --git a/Library/Homebrew/test/test_version_subclasses.rb b/Library/Homebrew/test/test_version_subclasses.rb
index 9261a7251..75ee2f286 100644
--- a/Library/Homebrew/test/test_version_subclasses.rb
+++ b/Library/Homebrew/test/test_version_subclasses.rb
@@ -44,4 +44,10 @@ class MacOSVersionTests < Homebrew::TestCase
assert_equal @v, MacOS::Version.from_symbol(:lion)
assert_raises(ArgumentError) { MacOS::Version.from_symbol(:foo) }
end
+
+ def test_pretty_name
+ assert_equal "El Capitan", MacOS::Version.new("10.11").pretty_name
+ assert_equal "Mountain Lion", MacOS::Version.new("10.8").pretty_name
+ assert_equal "Yosemite", MacOS::Version.new("10.10").pretty_name
+ end
end