test_tab: add test for Tab#spec

Fixes Homebrew/homebrew#42147.
Closes Homebrew/homebrew#42205.

Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
Xu Cheng 2015-07-31 16:14:26 +08:00
parent a9e71ca905
commit 8054161153
3 changed files with 42 additions and 2 deletions

View File

@ -9,9 +9,13 @@
],
"built_as_bottle": false,
"poured_from_bottle": true,
"tapped_from": "Homebrew/homebrew",
"time": 1403827774,
"HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
"stdlib": "libcxx",
"compiler": "clang"
"compiler": "clang",
"source": {
"path": "/usr/local/Library/Formula/foo.rb",
"tap": "Homebrew/homebrew",
"spec": "stable"
}
}

View File

@ -0,0 +1,17 @@
{
"used_options": [
"--with-foo",
"--without-bar"
],
"unused_options": [
"--with-baz",
"--without-qux"
],
"built_as_bottle": false,
"poured_from_bottle": true,
"tapped_from": "Homebrew/homebrew",
"time": 1403827774,
"HEAD": "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
"stdlib": "libcxx",
"compiler": "clang"
}

View File

@ -19,6 +19,7 @@ class TabTests < Homebrew::TestCase
"source" => {
"tap" => "Homebrew/homebrew",
"path" => nil,
"spec" => "stable",
},
})
end
@ -66,6 +67,22 @@ class TabTests < Homebrew::TestCase
assert_predicate @tab, :poured_from_bottle
end
def test_from_old_version_file
path = Pathname.new(TEST_DIRECTORY).join("fixtures", "receipt_old.json")
tab = Tab.from_file(path)
assert_equal @used.sort, tab.used_options.sort
assert_equal @unused.sort, tab.unused_options.sort
refute_predicate tab, :built_as_bottle
assert_predicate tab, :poured_from_bottle
assert_equal "Homebrew/homebrew", tab.tap
assert_equal :stable, tab.spec
refute_nil tab.time
assert_equal TEST_SHA1, tab.HEAD
assert_equal :clang, tab.cxxstdlib.compiler
assert_equal :libcxx, tab.cxxstdlib.type
end
def test_from_file
path = Pathname.new(TEST_DIRECTORY).join("fixtures", "receipt.json")
tab = Tab.from_file(path)
@ -75,6 +92,7 @@ class TabTests < Homebrew::TestCase
refute_predicate tab, :built_as_bottle
assert_predicate tab, :poured_from_bottle
assert_equal "Homebrew/homebrew", tab.tap
assert_equal :stable, tab.spec
refute_nil tab.time
assert_equal TEST_SHA1, tab.HEAD
assert_equal :clang, tab.cxxstdlib.compiler
@ -88,6 +106,7 @@ class TabTests < Homebrew::TestCase
assert_equal @tab.built_as_bottle, tab.built_as_bottle
assert_equal @tab.poured_from_bottle, tab.poured_from_bottle
assert_equal @tab.tap, tab.tap
assert_equal @tab.spec, tab.spec
assert_equal @tab.time, tab.time
assert_equal @tab.HEAD, tab.HEAD
assert_equal @tab.compiler, tab.compiler