Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
83482475
Commit
83482475
authored
8 years ago
by
Markus Reiter
Browse files
Options
Downloads
Patches
Plain Diff
Convert `formula_validation` test to spec.
parent
bb18f525
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/test/formula_validation_spec.rb
+94
-0
94 additions, 0 deletions
Library/Homebrew/test/formula_validation_spec.rb
Library/Homebrew/test/formula_validation_test.rb
+0
-75
0 additions, 75 deletions
Library/Homebrew/test/formula_validation_test.rb
with
94 additions
and
75 deletions
Library/Homebrew/test/formula_validation_spec.rb
0 → 100644
+
94
−
0
View file @
83482475
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
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/formula_validation_test.rb
deleted
100644 → 0
+
0
−
75
View file @
bb18f525
require
"testing_env"
require
"formula"
class
FormulaValidationTests
<
Homebrew
::
TestCase
def
assert_invalid
(
attr
,
&
block
)
e
=
assert_raises
(
FormulaValidationError
,
&
block
)
assert_equal
attr
,
e
.
attr
end
def
test_cant_override_brew
e
=
assert_raises
(
RuntimeError
)
{
formula
{
def
brew
;
end
}
}
assert_match
(
/You cannot override Formula#brew/
,
e
.
message
)
end
def
test_validates_name
assert_invalid
:name
do
formula
"name with spaces"
do
url
"foo"
version
"1.0"
end
end
end
def
test_validates_url
assert_invalid
:url
do
formula
do
url
""
version
"1"
end
end
end
def
test_validates_version
assert_invalid
:version
do
formula
do
url
"foo"
version
"version with spaces"
end
end
assert_invalid
:version
do
formula
do
url
"foo"
version
""
end
end
assert_invalid
:version
do
formula
do
url
"foo"
version
nil
end
end
end
def
test_devel_only_valid
f
=
formula
do
devel
do
url
"foo"
version
"1.0"
end
end
assert_predicate
f
,
:devel?
end
def
test_head_only_valid
f
=
formula
{
head
"foo"
}
assert_predicate
f
,
:head?
end
def
test_empty_formula_invalid
assert_raises
(
FormulaSpecificationError
)
{
formula
{}
}
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment