Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
fedede87
Commit
fedede87
authored
Dec 28, 2015
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[InstallationOptions] Add specs
parent
f4600471
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
3 deletions
+89
-3
installation_options.rb
lib/cocoapods/installer/installation_options.rb
+13
-3
installation_options_spec.rb
spec/unit/installer/installation_options_spec.rb
+76
-0
No files found.
lib/cocoapods/installer/installation_options.rb
View file @
fedede87
...
@@ -19,7 +19,7 @@ module Pod
...
@@ -19,7 +19,7 @@ module Pod
def
self
.
from_podfile
(
podfile
)
def
self
.
from_podfile
(
podfile
)
name
,
options
=
podfile
.
installation_method
name
,
options
=
podfile
.
installation_method
unless
name
.
downcase
==
'cocoapods'
unless
name
.
downcase
==
'cocoapods'
raise
Informative
"Currently need to specify a `cocoapods` install, you chose `
#{
name
}
`."
raise
Informative
,
"Currently need to specify a `cocoapods` install, you chose `
#{
name
}
`."
end
end
new
(
options
)
new
(
options
)
end
end
...
@@ -68,10 +68,10 @@ module Pod
...
@@ -68,10 +68,10 @@ module Pod
#
#
# @raise [Informative] if `options` contains any unknown keys.
# @raise [Informative] if `options` contains any unknown keys.
#
#
def
initialize
(
options
)
def
initialize
(
options
=
{}
)
options
=
ActiveSupport
::
HashWithIndifferentAccess
.
new
(
options
)
options
=
ActiveSupport
::
HashWithIndifferentAccess
.
new
(
options
)
unknown_keys
=
options
.
keys
-
self
.
class
.
all_options
.
map
(
&
:to_s
)
unknown_keys
=
options
.
keys
-
self
.
class
.
all_options
.
map
(
&
:to_s
)
raise
Informative
,
"Unknown installation options:
#{
unknown_keys
.
to_sentence
}
"
unless
unknown_keys
.
empty?
raise
Informative
,
"Unknown installation options:
#{
unknown_keys
.
to_sentence
}
.
"
unless
unknown_keys
.
empty?
self
.
class
.
defaults
.
each
do
|
key
,
default
|
self
.
class
.
defaults
.
each
do
|
key
,
default
|
value
=
options
.
fetch
(
key
,
default
)
value
=
options
.
fetch
(
key
,
default
)
send
(
"
#{
key
}
="
,
value
)
send
(
"
#{
key
}
="
,
value
)
...
@@ -91,6 +91,16 @@ module Pod
...
@@ -91,6 +91,16 @@ module Pod
end
end
end
end
def
==
(
other
)
other
.
is_a?
(
self
.
class
)
&&
to_h
==
other
.
to_h
end
alias_method
:eql
,
:==
def
hash
to_h
.
hash
end
option
:clean
,
true
option
:clean
,
true
option
:deduplicate_targets
,
true
option
:deduplicate_targets
,
true
option
:deterministic_uuids
,
true
option
:deterministic_uuids
,
true
...
...
spec/unit/installer/installation_options_spec.rb
0 → 100644
View file @
fedede87
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Installer
::
InstallationOptions
do
describe
'registered options'
do
{
'clean'
=>
true
,
'deduplicate_targets'
=>
true
,
'deterministic_uuids'
=>
true
,
'integrate_targets'
=>
true
,
'lock_pod_sources'
=>
true
,
}.
each
do
|
option
,
default
|
it
"includes `
#{
option
}
` defaulting to `
#{
default
}
`"
do
Installer
::
InstallationOptions
.
defaults
.
fetch
(
option
).
should
==
default
Installer
::
InstallationOptions
.
new
.
send
(
option
).
should
==
default
end
end
end
describe
'.from_podfile'
do
it
'raises for a non-cocoapods install'
do
podfile
=
Podfile
.
new
{
install!
'foo'
,
:key
=>
'value'
}
exception
=
should
.
raise
(
Informative
)
{
Installer
::
InstallationOptions
.
from_podfile
(
podfile
)
}
exception
.
message
.
should
.
include
'Currently need to specify a `cocoapods` install, you chose `foo`.'
end
it
'parses the name in a case-insensitive manner'
do
podfile
=
Podfile
.
new
{
install!
'CoCoApOdS'
}
should
.
not
.
raise
(
Informative
)
{
Installer
::
InstallationOptions
.
from_podfile
(
podfile
)
}
end
it
'uses the installation method options to create the options'
do
options
=
{
:integrate_targets
=>
false
}
podfile
=
Podfile
.
new
{
install!
'cocoapods'
,
options
}
installation_options
=
Installer
::
InstallationOptions
.
from_podfile
(
podfile
)
installation_options
.
should
==
Installer
::
InstallationOptions
.
new
(
options
)
end
end
describe
'#initialize'
do
it
'uses all defaults when no options are specified'
do
Installer
::
InstallationOptions
.
new
.
to_h
(
:include_defaults
=>
false
).
should
.
be
.
empty
end
it
'sets the values as specified in the options'
do
installation_options
=
Installer
::
InstallationOptions
.
new
(
:deterministic_uuids
=>
false
)
installation_options
.
deterministic_uuids
.
should
.
be
.
false
end
it
'raises when unknown keys are encountered'
do
exception
=
should
.
raise
(
Informative
)
{
Installer
::
InstallationOptions
.
new
(
:a
=>
'a'
,
:b
=>
'b'
,
:c
=>
'c'
)
}
exception
.
message
.
should
.
include
'Unknown installation options: a, b, and c.'
end
end
describe
'#to_h'
do
it
'includes all options by default'
do
installation_options
=
Installer
::
InstallationOptions
.
new
(
:deterministic_uuids
=>
false
)
installation_options
.
to_h
.
should
==
{
'clean'
=>
true
,
'deduplicate_targets'
=>
true
,
'deterministic_uuids'
=>
false
,
'integrate_targets'
=>
true
,
'lock_pod_sources'
=>
true
,
}
end
it
'removes default values when specified'
do
installation_options
=
Installer
::
InstallationOptions
.
new
(
:deterministic_uuids
=>
false
)
installation_options
.
to_h
(
:include_defaults
=>
false
).
should
==
{
'deterministic_uuids'
=>
false
,
}
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment