From c6784f606f5c1116ecc7c8351b5995d0ac0735f0 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 27 Feb 2017 14:58:57 +0100 Subject: [PATCH] Convert formula_spec_selection test to spec. --- .../test/formula_spec_selection_spec.rb | 100 ++++++++++++++++++ .../test/formula_spec_selection_test.rb | 99 ----------------- 2 files changed, 100 insertions(+), 99 deletions(-) create mode 100644 Library/Homebrew/test/formula_spec_selection_spec.rb delete mode 100644 Library/Homebrew/test/formula_spec_selection_test.rb diff --git a/Library/Homebrew/test/formula_spec_selection_spec.rb b/Library/Homebrew/test/formula_spec_selection_spec.rb new file mode 100644 index 0000000000..20231ffda2 --- /dev/null +++ b/Library/Homebrew/test/formula_spec_selection_spec.rb @@ -0,0 +1,100 @@ +require "formula" + +describe Formula do + describe "::new" do + it "selects stable by default" do + f = formula do + url "foo-1.0" + devel { url "foo-1.1a" } + head "foo" + end + + expect(f).to be_stable + end + + it "selects stable when exclusive" do + f = formula { url "foo-1.0" } + expect(f).to be_stable + end + + it "selects devel before HEAD" do + f = formula do + devel { url "foo-1.1a" } + head "foo" + end + + expect(f).to be_devel + end + + it "selects devel when exclusive" do + f = formula { devel { url "foo-1.1a" } } + expect(f).to be_devel + end + + it "selects HEAD when exclusive" do + f = formula { head "foo" } + expect(f).to be_head + end + + it "does not select an incomplete spec" do + f = formula do + sha256 TEST_SHA256 + version "1.0" + head "foo" + end + + expect(f).to be_head + end + + it "does not set an incomplete stable spec" do + f = formula do + sha256 TEST_SHA256 + devel { url "foo-1.1a" } + head "foo" + end + + expect(f.stable).to be nil + expect(f).to be_devel + end + + it "selects HEAD when requested" do + f = formula("test", spec: :head) do + url "foo-1.0" + devel { url "foo-1.1a" } + head "foo" + end + + expect(f).to be_head + end + + it "selects devel when requested" do + f = formula("test", spec: :devel) do + url "foo-1.0" + devel { url "foo-1.1a" } + head "foo" + end + + expect(f).to be_devel + end + + it "does not set an incomplete devel spec" do + f = formula do + url "foo-1.0" + devel { version "1.1a" } + head "foo" + end + + expect(f.devel).to be nil + expect(f).to be_stable + end + + it "does not raise an error for a missing spec" do + f = formula("test", spec: :devel) do + url "foo-1.0" + head "foo" + end + + expect(f).to be_stable + end + end +end diff --git a/Library/Homebrew/test/formula_spec_selection_test.rb b/Library/Homebrew/test/formula_spec_selection_test.rb deleted file mode 100644 index 7148df173a..0000000000 --- a/Library/Homebrew/test/formula_spec_selection_test.rb +++ /dev/null @@ -1,99 +0,0 @@ -require "testing_env" -require "formula" - -class FormulaSpecSelectionTests < Homebrew::TestCase - def test_selects_stable_by_default - f = formula do - url "foo-1.0" - devel { url "foo-1.1a" } - head "foo" - end - - assert_predicate f, :stable? - end - - def test_selects_stable_when_exclusive - f = formula { url "foo-1.0" } - assert_predicate f, :stable? - end - - def test_selects_devel_before_head - f = formula do - devel { url "foo-1.1a" } - head "foo" - end - - assert_predicate f, :devel? - end - - def test_selects_devel_when_exclusive - f = formula { devel { url "foo-1.1a" } } - assert_predicate f, :devel? - end - - def test_selects_head_when_exclusive - f = formula { head "foo" } - assert_predicate f, :head? - end - - def test_incomplete_spec_not_selected - f = formula do - sha256 TEST_SHA256 - version "1.0" - head "foo" - end - - assert_predicate f, :head? - end - - def test_incomplete_stable_not_set - f = formula do - sha256 TEST_SHA256 - devel { url "foo-1.1a" } - head "foo" - end - - assert_nil f.stable - assert_predicate f, :devel? - end - - def test_selects_head_when_requested - f = formula("test", Pathname.new(__FILE__).expand_path, :head) do - url "foo-1.0" - devel { url "foo-1.1a" } - head "foo" - end - - assert_predicate f, :head? - end - - def test_selects_devel_when_requested - f = formula("test", Pathname.new(__FILE__).expand_path, :devel) do - url "foo-1.0" - devel { url "foo-1.1a" } - head "foo" - end - - assert_predicate f, :devel? - end - - def test_incomplete_devel_not_set - f = formula do - url "foo-1.0" - devel { version "1.1a" } - head "foo" - end - - assert_nil f.devel - assert_predicate f, :stable? - end - - def test_does_not_raise_for_missing_spec - f = formula("test", Pathname.new(__FILE__).expand_path, :devel) do - url "foo-1.0" - head "foo" - end - - assert_predicate f, :stable? - end -end