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
e5e8f545
Commit
e5e8f545
authored
8 years ago
by
Markus Reiter
Browse files
Options
Downloads
Patches
Plain Diff
Convert Artifact::Pkg test to spec.
parent
3db8cdf8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb
+71
-0
71 additions, 0 deletions
Library/Homebrew/cask/spec/cask/artifact/pkg_spec.rb
with
71 additions
and
0 deletions
Library/Homebrew/cask/
test
/cask/artifact/pkg_
test
.rb
→
Library/Homebrew/cask/
spec
/cask/artifact/pkg_
spec
.rb
+
71
−
0
View file @
e5e8f545
require
"
test
_helper"
require
"
spec
_helper"
describe
Hbc
::
Artifact
::
Pkg
do
before
do
@cask
=
Hbc
::
CaskLoader
.
load_from_file
(
TEST_FIXTURE_DIR
/
"cask/Casks/with-installable.rb"
)
let
(
:cask
)
{
Hbc
::
CaskLoader
.
load_from_file
(
TEST_FIXTURE_DIR
/
"cask/Casks/with-installable.rb"
)
}
let
(
:fake_system_command
)
{
class_double
(
Hbc
::
SystemCommand
)
}
before
(
:each
)
do
shutup
do
Test
Helper
.
install_without_artifacts
(
@
cask
)
Install
Helper
.
install_without_artifacts
(
cask
)
end
end
describe
"install_phase"
do
it
"runs the system installer on the specified pkgs"
do
pkg
=
Hbc
::
Artifact
::
Pkg
.
new
(
@cask
,
command:
Hbc
::
FakeSystemCommand
)
pkg
=
Hbc
::
Artifact
::
Pkg
.
new
(
cask
,
command:
fake_system_command
)
Hbc
::
FakeSystemCommand
.
expects_command
([
"/usr/bin/sudo"
,
"-E"
,
"--"
,
"/usr/sbin/installer"
,
"-pkg"
,
@cask
.
staged_path
.
join
(
"MyFancyPkg"
,
"Fancy.pkg"
),
"-target"
,
"/"
])
expect
(
fake_system_command
).
to
receive
(
:run!
).
with
(
"/usr/sbin/installer"
,
args:
[
"-pkg"
,
cask
.
staged_path
.
join
(
"MyFancyPkg"
,
"Fancy.pkg"
),
"-target"
,
"/"
],
sudo:
true
,
print_stdout:
true
)
shutup
do
pkg
.
install_phase
...
...
@@ -22,18 +28,14 @@ describe Hbc::Artifact::Pkg do
end
describe
"choices"
do
before
do
@cask
=
Hbc
::
CaskLoader
.
load_from_file
(
TEST_FIXTURE_DIR
/
"cask/Casks/with-choices.rb"
)
shutup
do
TestHelper
.
install_without_artifacts
(
@cask
)
end
end
let
(
:cask
)
{
Hbc
::
CaskLoader
.
load_from_file
(
TEST_FIXTURE_DIR
/
"cask/Casks/with-choices.rb"
)
}
it
"passes the choice changes xml to the system installer"
do
pkg
=
Hbc
::
Artifact
::
Pkg
.
new
(
@cask
,
command:
Hbc
::
FakeSystemCommand
)
pkg
=
Hbc
::
Artifact
::
Pkg
.
new
(
cask
,
command:
fake_system_command
)
file
=
double
(
path:
Pathname
.
new
(
"/tmp/choices.xml"
))
file
=
mock
file
.
expects
(
:write
).
with
<<-
EOS
.
undent
expect
(
file
).
to
receive
(
:write
).
with
(
<<-
EOS
.
undent
)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
...
...
@@ -49,12 +51,17 @@ describe Hbc::Artifact::Pkg do
</array>
</plist>
EOS
file
.
stubs
path:
Pathname
.
new
(
"/tmp/choices.xml"
)
file
.
expects
(
:close
)
file
.
expects
(
:unlink
)
Tempfile
.
expects
(
:open
).
yields
file
Hbc
::
FakeSystemCommand
.
expects_command
([
"/usr/bin/sudo"
,
"-E"
,
"--"
,
"/usr/sbin/installer"
,
"-pkg"
,
@cask
.
staged_path
.
join
(
"MyFancyPkg"
,
"Fancy.pkg"
),
"-target"
,
"/"
,
"-applyChoiceChangesXML"
,
@cask
.
staged_path
.
join
(
"/tmp/choices.xml"
)])
expect
(
file
).
to
receive
(
:close
)
expect
(
file
).
to
receive
(
:unlink
)
expect
(
Tempfile
).
to
receive
(
:open
).
and_yield
(
file
)
expect
(
fake_system_command
).
to
receive
(
:run!
).
with
(
"/usr/sbin/installer"
,
args:
[
"-pkg"
,
cask
.
staged_path
.
join
(
"MyFancyPkg"
,
"Fancy.pkg"
),
"-target"
,
"/"
,
"-applyChoiceChangesXML"
,
cask
.
staged_path
.
join
(
"/tmp/choices.xml"
)],
sudo:
true
,
print_stdout:
true
)
shutup
do
pkg
.
install_phase
...
...
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