diff --git a/Library/Homebrew/test/fixtures/receipt.json b/Library/Homebrew/test/fixtures/receipt.json index 955d56b47f..8a3adc672a 100644 --- a/Library/Homebrew/test/fixtures/receipt.json +++ b/Library/Homebrew/test/fixtures/receipt.json @@ -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" + } } diff --git a/Library/Homebrew/test/fixtures/receipt_old.json b/Library/Homebrew/test/fixtures/receipt_old.json new file mode 100644 index 0000000000..955d56b47f --- /dev/null +++ b/Library/Homebrew/test/fixtures/receipt_old.json @@ -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" +} diff --git a/Library/Homebrew/test/test_tab.rb b/Library/Homebrew/test/test_tab.rb index eebfe9be34..af537267cd 100644 --- a/Library/Homebrew/test/test_tab.rb +++ b/Library/Homebrew/test/test_tab.rb @@ -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