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
7b2d8ed4
Commit
7b2d8ed4
authored
8 years ago
by
Markus Reiter
Browse files
Options
Downloads
Patches
Plain Diff
Convert Options test to spec.
parent
bcaa13b7
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/cask/spec/cask/cli/options_spec.rb
+23
-27
23 additions, 27 deletions
Library/Homebrew/cask/spec/cask/cli/options_spec.rb
Library/Homebrew/cask/spec/spec_helper.rb
+27
-5
27 additions, 5 deletions
Library/Homebrew/cask/spec/spec_helper.rb
with
50 additions
and
32 deletions
Library/Homebrew/cask/
test
/cask/cli/options_
test
.rb
→
Library/Homebrew/cask/
spec
/cask/cli/options_
spec
.rb
+
23
−
27
View file @
7b2d8ed4
require
"
test
_helper"
require
"
spec
_helper"
describe
Hbc
::
CLI
do
it
"supports setting the appdir"
do
Hbc
::
CLI
.
process_options
%w[help --appdir=/some/path/foo]
Hbc
.
appdir
.
must_equal
Pathname
(
"/some/path/foo"
)
expect
(
Hbc
.
appdir
).
to
eq
(
Pathname
.
new
(
"/some/path/foo"
)
)
end
it
"supports setting the appdir from ENV"
do
...
...
@@ -12,13 +12,13 @@ describe Hbc::CLI do
Hbc
::
CLI
.
process_options
%w[help]
Hbc
.
appdir
.
must_equal
Pathname
(
"/some/path/bar"
)
expect
(
Hbc
.
appdir
).
to
eq
(
Pathname
.
new
(
"/some/path/bar"
)
)
end
it
"supports setting the prefpanedir"
do
Hbc
::
CLI
.
process_options
%w[help --prefpanedir=/some/path/foo]
Hbc
.
prefpanedir
.
must_equal
Pathname
(
"/some/path/foo"
)
expect
(
Hbc
.
prefpanedir
).
to
eq
(
Pathname
.
new
(
"/some/path/foo"
)
)
end
it
"supports setting the prefpanedir from ENV"
do
...
...
@@ -26,13 +26,13 @@ describe Hbc::CLI do
Hbc
::
CLI
.
process_options
%w[help]
Hbc
.
prefpanedir
.
must_equal
Pathname
(
"/some/path/bar"
)
expect
(
Hbc
.
prefpanedir
).
to
eq
(
Pathname
.
new
(
"/some/path/bar"
)
)
end
it
"supports setting the qlplugindir"
do
Hbc
::
CLI
.
process_options
%w[help --qlplugindir=/some/path/foo]
Hbc
.
qlplugindir
.
must_equal
Pathname
(
"/some/path/foo"
)
expect
(
Hbc
.
qlplugindir
).
to
eq
(
Pathname
.
new
(
"/some/path/foo"
)
)
end
it
"supports setting the qlplugindir from ENV"
do
...
...
@@ -40,13 +40,13 @@ describe Hbc::CLI do
Hbc
::
CLI
.
process_options
%w[help]
Hbc
.
qlplugindir
.
must_equal
Pathname
(
"/some/path/bar"
)
expect
(
Hbc
.
qlplugindir
).
to
eq
(
Pathname
.
new
(
"/some/path/bar"
)
)
end
it
"supports setting the colorpickerdir"
do
Hbc
::
CLI
.
process_options
%w[help --colorpickerdir=/some/path/foo]
Hbc
.
colorpickerdir
.
must_equal
Pathname
(
"/some/path/foo"
)
expect
(
Hbc
.
colorpickerdir
).
to
eq
(
Pathname
.
new
(
"/some/path/foo"
)
)
end
it
"supports setting the colorpickerdir from ENV"
do
...
...
@@ -54,13 +54,13 @@ describe Hbc::CLI do
Hbc
::
CLI
.
process_options
%w[help]
Hbc
.
colorpickerdir
.
must_equal
Pathname
(
"/some/path/bar"
)
expect
(
Hbc
.
colorpickerdir
).
to
eq
(
Pathname
.
new
(
"/some/path/bar"
)
)
end
it
"supports setting the dictionarydir"
do
Hbc
::
CLI
.
process_options
%w[help --dictionarydir=/some/path/foo]
Hbc
.
dictionarydir
.
must_equal
Pathname
(
"/some/path/foo"
)
expect
(
Hbc
.
dictionarydir
).
to
eq
(
Pathname
.
new
(
"/some/path/foo"
)
)
end
it
"supports setting the dictionarydir from ENV"
do
...
...
@@ -68,13 +68,13 @@ describe Hbc::CLI do
Hbc
::
CLI
.
process_options
%w[help]
Hbc
.
dictionarydir
.
must_equal
Pathname
(
"/some/path/bar"
)
expect
(
Hbc
.
dictionarydir
).
to
eq
(
Pathname
.
new
(
"/some/path/bar"
)
)
end
it
"supports setting the fontdir"
do
Hbc
::
CLI
.
process_options
%w[help --fontdir=/some/path/foo]
Hbc
.
fontdir
.
must_equal
Pathname
(
"/some/path/foo"
)
expect
(
Hbc
.
fontdir
).
to
eq
(
Pathname
.
new
(
"/some/path/foo"
)
)
end
it
"supports setting the fontdir from ENV"
do
...
...
@@ -82,13 +82,13 @@ describe Hbc::CLI do
Hbc
::
CLI
.
process_options
%w[help]
Hbc
.
fontdir
.
must_equal
Pathname
(
"/some/path/bar"
)
expect
(
Hbc
.
fontdir
).
to
eq
(
Pathname
.
new
(
"/some/path/bar"
)
)
end
it
"supports setting the servicedir"
do
Hbc
::
CLI
.
process_options
%w[help --servicedir=/some/path/foo]
Hbc
.
servicedir
.
must_equal
Pathname
(
"/some/path/foo"
)
expect
(
Hbc
.
servicedir
).
to
eq
(
Pathname
.
new
(
"/some/path/foo"
)
)
end
it
"supports setting the servicedir from ENV"
do
...
...
@@ -96,36 +96,36 @@ describe Hbc::CLI do
Hbc
::
CLI
.
process_options
%w[help]
Hbc
.
servicedir
.
must_equal
Pathname
(
"/some/path/bar"
)
expect
(
Hbc
.
servicedir
).
to
eq
(
Pathname
.
new
(
"/some/path/bar"
)
)
end
it
"allows additional options to be passed through"
do
rest
=
Hbc
::
CLI
.
process_options
%w[edit foo --create --appdir=/some/path/qux]
Hbc
.
appdir
.
must_equal
Pathname
(
"/some/path/qux"
)
rest
.
must_equal
%w[edit foo --create]
expect
(
Hbc
.
appdir
).
to
eq
(
Pathname
.
new
(
"/some/path/qux"
)
)
expect
(
rest
).
to
eq
(
%w[edit foo --create]
)
end
describe
"when a mandatory argument is missing"
do
it
"shows a user-friendly error message"
do
lambda
{
expect
{
Hbc
::
CLI
.
process_options
%w[install -f]
}.
must_raise
Hbc
::
CaskError
}.
to
raise_error
(
Hbc
::
CaskError
)
end
end
describe
"given an ambiguous option"
do
it
"shows a user-friendly error message"
do
lambda
{
expect
{
Hbc
::
CLI
.
process_options
%w[edit -c]
}.
must_raise
Hbc
::
CaskError
}.
to
raise_error
(
Hbc
::
CaskError
)
end
end
describe
"--debug"
do
it
"sets the Cask debug method to true"
do
Hbc
::
CLI
.
process_options
%w[help --debug]
Hbc
.
debug
.
must_equal
true
expect
(
Hbc
.
debug
).
to
be
true
Hbc
.
debug
=
false
end
end
...
...
@@ -133,12 +133,8 @@ describe Hbc::CLI do
describe
"--help"
do
it
"sets the Cask help method to true"
do
Hbc
::
CLI
.
process_options
%w[foo --help]
Hbc
.
help
.
must_equal
true
expect
(
Hbc
.
help
).
to
be
true
Hbc
.
help
=
false
end
end
after
do
ENV
[
"HOMEBREW_CASK_OPTS"
]
=
nil
end
end
This diff is collapsed.
Click to expand it.
Library/Homebrew/cask/spec/spec_helper.rb
+
27
−
5
View file @
7b2d8ed4
...
...
@@ -37,11 +37,33 @@ FileUtils.ln_s Pathname.new(ENV["HOMEBREW_LIBRARY"]).join("Taps", "caskroom", "h
RSpec
.
configure
do
|
config
|
config
.
order
=
:random
config
.
include
(
Test
::
Helper
::
Shutup
)
config
.
after
(
:each
)
do
FileUtils
.
rm_rf
[
Hbc
.
appdir
.
children
,
Hbc
.
caskroom
.
children
,
]
config
.
around
(
:each
)
do
|
example
|
begin
@__appdir
=
Hbc
.
appdir
@__caskroom
=
Hbc
.
caskroom
@__prefpanedir
=
Hbc
.
prefpanedir
@__qlplugindir
=
Hbc
.
qlplugindir
@__servicedir
=
Hbc
.
servicedir
@__argv
=
ARGV
.
dup
@__env
=
ENV
.
to_hash
# dup doesn't work on ENV
example
.
run
ensure
ARGV
.
replace
(
@__argv
)
ENV
.
replace
(
@__env
)
Hbc
.
appdir
=
@__appdir
Hbc
.
caskroom
=
@__caskroom
Hbc
.
prefpanedir
=
@__prefpanedir
Hbc
.
qlplugindir
=
@__qlplugindir
Hbc
.
servicedir
=
@__servicedir
FileUtils
.
rm_rf
[
Hbc
.
appdir
.
children
,
Hbc
.
caskroom
.
children
,
]
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