aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2014-06-29 21:49:34 -0500
committerJack Nagel2014-06-29 21:49:34 -0500
commit4d11def53c236de9ee7d5819f219137063572551 (patch)
treeb7249f2700fca1ba7d974008a921ce67e5c85d53 /Library
parent34db1bd1efc0204a4a8c8c77e12eb233980c7576 (diff)
downloadbrew-4d11def53c236de9ee7d5819f219137063572551.tar.bz2
Add tests documenting install receipt loading behavior
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/test_tab.rb58
1 files changed, 58 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_tab.rb b/Library/Homebrew/test/test_tab.rb
index 4cc00818a..912a207a9 100644
--- a/Library/Homebrew/test/test_tab.rb
+++ b/Library/Homebrew/test/test_tab.rb
@@ -1,5 +1,6 @@
require "testing_env"
require "tab"
+require "formula"
class TabTests < Homebrew::TestCase
def setup
@@ -85,3 +86,60 @@ class TabTests < Homebrew::TestCase
assert_equal :libcxx, tab.cxxstdlib.type
end
end
+
+class TabLoadingTests < Homebrew::TestCase
+ def setup
+ @f = formula { url "foo-1.0" }
+ @f.prefix.mkpath
+ @path = @f.prefix.join(Tab::FILENAME)
+ @path.write Pathname.new(TEST_DIRECTORY).join("fixtures", "receipt.json").read
+ @path = @path.realpath
+ end
+
+ def teardown
+ @f.rack.rmtree
+ end
+
+ def test_for_keg
+ tab = Tab.for_keg(@f.prefix)
+ assert_equal @path, tab.tabfile
+ end
+
+ def test_for_keg_nonexistent_path
+ @path.unlink
+ tab = Tab.for_keg(@f.prefix)
+ assert_nil tab.tabfile
+ end
+
+ def test_for_formula
+ tab = Tab.for_formula(@f)
+ assert_equal @path, tab.tabfile
+ end
+
+ def test_for_formula_nonexistent_path
+ @path.unlink
+ tab = Tab.for_formula(@f)
+ assert_nil tab.tabfile
+ end
+
+ def test_for_formula_multiple_kegs
+ f2 = formula { url "foo-2.0" }
+ f2.prefix.mkpath
+
+ assert_equal @f.rack, f2.rack
+ assert_equal 2, @f.rack.subdirs.length
+
+ tab = Tab.for_formula(@f)
+ assert_equal @path, tab.tabfile
+ end
+
+ def test_for_formula_outdated_keg
+ f2 = formula { url "foo-2.0" }
+
+ assert_equal @f.rack, f2.rack
+ assert_equal 1, @f.rack.subdirs.length
+
+ tab = Tab.for_formula(f2)
+ assert_equal @path, tab.tabfile
+ end
+end