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
37ecdb28
Commit
37ecdb28
authored
4 years ago
by
Markus Reiter
Browse files
Options
Downloads
Patches
Plain Diff
Add spec for `NamedArgs#to_paths`.
parent
2a63ba40
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/cli/named_args.rb
+1
-1
1 addition, 1 deletion
Library/Homebrew/cli/named_args.rb
Library/Homebrew/test/cli/named_args_spec.rb
+41
-0
41 additions, 0 deletions
Library/Homebrew/test/cli/named_args_spec.rb
with
42 additions
and
1 deletion
Library/Homebrew/cli/named_args.rb
+
1
−
1
View file @
37ecdb28
...
...
@@ -84,7 +84,7 @@ module Homebrew
@to_paths
||=
{}
@to_paths
[
only
]
||=
downcased_unique_named
.
flat_map
do
|
name
|
if
File
.
exist?
(
name
)
name
Pathname
(
name
)
elsif
name
.
count
(
"/"
)
==
1
Tap
.
fetch
(
name
).
path
else
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/test/cli/named_args_spec.rb
+
41
−
0
View file @
37ecdb28
...
...
@@ -120,4 +120,45 @@ describe Homebrew::CLI::NamedArgs do
expect
(
described_class
.
new
(
"foo"
).
homebrew_tap_cask_names
).
to
be_empty
end
end
describe
"#to_paths"
do
let
(
:existing_path
)
{
mktmpdir
}
let
(
:formula_path
)
{
Pathname
(
"/path/to/foo.rb"
)
}
let
(
:cask_path
)
{
Pathname
(
"/path/to/baz.rb"
)
}
before
do
allow
(
formula_path
).
to
receive
(
:exist?
).
and_return
(
true
)
allow
(
cask_path
).
to
receive
(
:exist?
).
and_return
(
true
)
allow
(
Formulary
).
to
receive
(
:path
).
and_call_original
allow
(
Cask
::
CaskLoader
).
to
receive
(
:path
).
and_call_original
end
it
"returns taps, cask formula and existing paths"
do
expect
(
Formulary
).
to
receive
(
:path
).
with
(
"foo"
).
and_return
(
formula_path
)
expect
(
Cask
::
CaskLoader
).
to
receive
(
:path
).
with
(
"baz"
).
and_return
(
cask_path
)
expect
(
described_class
.
new
(
"homebrew/core"
,
"foo"
,
"baz"
,
existing_path
.
to_s
).
to_paths
)
.
to
eq
[
Tap
.
fetch
(
"homebrew/core"
).
path
,
formula_path
,
cask_path
,
existing_path
]
end
it
"returns both cask and formula paths if they exist"
do
expect
(
Formulary
).
to
receive
(
:path
).
with
(
"foo"
).
and_return
(
formula_path
)
expect
(
Cask
::
CaskLoader
).
to
receive
(
:path
).
with
(
"baz"
).
and_return
(
cask_path
)
expect
(
described_class
.
new
(
"foo"
,
"baz"
).
to_paths
).
to
eq
[
formula_path
,
cask_path
]
end
it
"returns only formulae when `only: :formulae` is specified"
do
expect
(
Formulary
).
to
receive
(
:path
).
with
(
"foo"
).
and_return
(
formula_path
)
expect
(
described_class
.
new
(
"foo"
,
"baz"
).
to_paths
(
only: :formulae
)).
to
eq
[
formula_path
,
Formulary
.
path
(
"baz"
)]
end
it
"returns only casks when `only: :casks` is specified"
do
expect
(
Cask
::
CaskLoader
).
to
receive
(
:path
).
with
(
"foo"
).
and_return
(
cask_path
)
expect
(
described_class
.
new
(
"foo"
,
"baz"
).
to_paths
(
only: :casks
)).
to
eq
[
cask_path
,
Cask
::
CaskLoader
.
path
(
"baz"
)]
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