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
8676960d
Commit
8676960d
authored
8 years ago
by
Markus Reiter
Browse files
Options
Downloads
Patches
Plain Diff
Convert FormulaText test to spec.
parent
14ae87d5
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/audit_test.rb
+0
-49
0 additions, 49 deletions
Library/Homebrew/test/audit_test.rb
Library/Homebrew/test/dev-cmd/audit_spec.rb
+61
-0
61 additions, 0 deletions
Library/Homebrew/test/dev-cmd/audit_spec.rb
with
61 additions
and
49 deletions
Library/Homebrew/test/audit_test.rb
+
0
−
49
View file @
8676960d
...
@@ -4,55 +4,6 @@ require "pathname"
...
@@ -4,55 +4,6 @@ require "pathname"
require
"formulary"
require
"formulary"
require
"dev-cmd/audit"
require
"dev-cmd/audit"
class
FormulaTextTests
<
Homebrew
::
TestCase
def
setup
super
@dir
=
mktmpdir
end
def
formula_text
(
name
,
body
=
nil
,
options
=
{})
path
=
Pathname
.
new
"
#{
@dir
}
/
#{
name
}
.rb"
path
.
open
(
"w"
)
do
|
f
|
f
.
write
<<-
EOS
.
undent
class
#{
Formulary
.
class_s
(
name
)
}
< Formula
#{
body
}
end
#{
options
[
:patch
]
}
EOS
end
FormulaText
.
new
path
end
def
test_simple_valid_formula
ft
=
formula_text
"valid"
,
'url "http://www.example.com/valid-1.0.tar.gz"'
refute
ft
.
data?
,
"The formula should not have DATA"
refute
ft
.
end?
,
"The formula should not have __END__"
assert
ft
.
trailing_newline?
,
"The formula should have a trailing newline"
assert
ft
=~
/\burl\b/
,
"The formula should match 'url'"
assert_nil
ft
.
line_number
(
/desc/
),
"The formula should not match 'desc'"
assert_equal
2
,
ft
.
line_number
(
/\burl\b/
)
assert
ft
.
include?
(
"Valid"
),
"The formula should include
\"
Valid
\"
"
end
def
test_trailing_newline
ft
=
formula_text
"newline"
assert
ft
.
trailing_newline?
,
"The formula must have a trailing newline"
end
def
test_has_data
ft
=
formula_text
"data"
,
"patch :DATA"
assert
ft
.
data?
,
"The formula must have DATA"
end
def
test_has_end
ft
=
formula_text
"end"
,
""
,
patch:
"__END__
\n
a patch here"
assert
ft
.
end?
,
"The formula must have __END__"
assert_equal
"class End < Formula
\n
\n
end"
,
ft
.
without_patch
end
end
class
FormulaAuditorTests
<
Homebrew
::
TestCase
class
FormulaAuditorTests
<
Homebrew
::
TestCase
def
setup
def
setup
super
super
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/dev-cmd/audit_spec.rb
0 → 100644
+
61
−
0
View file @
8676960d
require
"dev-cmd/audit"
require
"formulary"
RSpec
::
Matchers
.
alias_matcher
:have_data
,
:be_data
RSpec
::
Matchers
.
alias_matcher
:have_end
,
:be_end
RSpec
::
Matchers
.
alias_matcher
:have_trailing_newline
,
:be_trailing_newline
describe
FormulaText
do
let
(
:dir
)
{
@dir
=
Pathname
.
new
(
Dir
.
mktmpdir
)
}
after
(
:each
)
do
dir
.
rmtree
unless
@dir
.
nil?
end
def
formula_text
(
name
,
body
=
nil
,
options
=
{})
path
=
dir
/
"
#{
name
}
.rb"
path
.
write
<<-
EOS
.
undent
class
#{
Formulary
.
class_s
(
name
)
}
< Formula
#{
body
}
end
#{
options
[
:patch
]
}
EOS
described_class
.
new
(
path
)
end
specify
"simple valid Formula"
do
ft
=
formula_text
"valid"
,
<<-
EOS
.
undent
url "http://www.example.com/valid-1.0.tar.gz"
EOS
expect
(
ft
).
not_to
have_data
expect
(
ft
).
not_to
have_end
expect
(
ft
).
to
have_trailing_newline
expect
(
ft
=~
/\burl\b/
).
to
be_truthy
expect
(
ft
.
line_number
(
/desc/
)).
to
be
nil
expect
(
ft
.
line_number
(
/\burl\b/
)).
to
eq
(
2
)
expect
(
ft
).
to
include
(
"Valid"
)
end
specify
"#trailing_newline?"
do
ft
=
formula_text
"newline"
expect
(
ft
).
to
have_trailing_newline
end
specify
"#data?"
do
ft
=
formula_text
"data"
,
<<-
EOS
.
undent
patch :DATA
EOS
expect
(
ft
).
to
have_data
end
specify
"#end?"
do
ft
=
formula_text
"end"
,
""
,
patch:
"__END__
\n
a patch here"
expect
(
ft
).
to
have_end
expect
(
ft
.
without_patch
).
to
eq
(
"class End < Formula
\n
\n
end"
)
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