diff options
| author | Markus Reiter | 2017-02-27 22:08:58 +0100 |
|---|---|---|
| committer | GitHub | 2017-02-27 22:08:58 +0100 |
| commit | d2c9424cffd38b74a4b8dae10126bf879f1790bc (patch) | |
| tree | 6e5bb6036a54479da99d2db7fac6b6d1397d3b2e /Library/Homebrew/test/formula_validation_spec.rb | |
| parent | 6392f5f081fce08e44fe3979eb8df1c4dc0af06e (diff) | |
| parent | 834824754f1837aceefe0518b7fe4023053ecfff (diff) | |
| download | brew-d2c9424cffd38b74a4b8dae10126bf879f1790bc.tar.bz2 | |
Merge pull request #2221 from reitermarkus/spec-formula_validation
Convert `formula_validation` test to spec.
Diffstat (limited to 'Library/Homebrew/test/formula_validation_spec.rb')
| -rw-r--r-- | Library/Homebrew/test/formula_validation_spec.rb | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/Library/Homebrew/test/formula_validation_spec.rb b/Library/Homebrew/test/formula_validation_spec.rb new file mode 100644 index 000000000..ff50c86d1 --- /dev/null +++ b/Library/Homebrew/test/formula_validation_spec.rb @@ -0,0 +1,94 @@ +require "formula" + +describe Formula do + describe "::new" do + matcher :fail_with_invalid do |attr| + match do |actual| + expect { + begin + actual.call + rescue => e + expect(e.attr).to eq(attr) + raise e + end + }.to raise_error(FormulaValidationError) + end + + def supports_block_expectations? + true + end + end + + it "cant override the `brew` method" do + expect { + formula do + def brew; end + end + }.to raise_error(RuntimeError, /You cannot override Formula#brew/) + end + + it "validates the `name`" do + expect { + formula "name with spaces" do + url "foo" + version "1.0" + end + }.to fail_with_invalid :name + end + + it "validates the `url`" do + expect { + formula do + url "" + version "1" + end + }.to fail_with_invalid :url + end + + it "validates the `version`" do + expect { + formula do + url "foo" + version "version with spaces" + end + }.to fail_with_invalid :version + + expect { + formula do + url "foo" + version "" + end + }.to fail_with_invalid :version + + expect { + formula do + url "foo" + version nil + end + }.to fail_with_invalid :version + end + + specify "devel-only is valid" do + f = formula do + devel do + url "foo" + version "1.0" + end + end + + expect(f).to be_devel + end + + specify "head-only is valid" do + f = formula do + head "foo" + end + + expect(f).to be_head + end + + it "fails when Formula is empty" do + expect { formula {} }.to raise_error(FormulaSpecificationError) + end + end +end |
