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
f88e26c1
Commit
f88e26c1
authored
Jul 13, 2012
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[HEAD] Move logic from Specification to Installer/Downloader.
Closes #392. Incidentally touched ALL THE FILES.
parent
a24b4ba3
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
210 additions
and
162 deletions
+210
-162
dependency.rb
lib/cocoapods/dependency.rb
+18
-12
git.rb
lib/cocoapods/downloader/git.rb
+2
-2
installer.rb
lib/cocoapods/installer.rb
+17
-5
resolver.rb
lib/cocoapods/resolver.rb
+2
-1
specification.rb
lib/cocoapods/specification.rb
+4
-31
version.rb
lib/cocoapods/version.rb
+2
-0
downloader_spec.rb
spec/functional/downloader_spec.rb
+35
-33
dependency_spec.rb
spec/unit/dependency_spec.rb
+46
-24
downloader_spec.rb
spec/unit/downloader_spec.rb
+16
-18
installer_spec.rb
spec/unit/installer_spec.rb
+27
-10
resolver_spec.rb
spec/unit/resolver_spec.rb
+41
-26
No files found.
lib/cocoapods/dependency.rb
View file @
f88e26c1
...
@@ -6,8 +6,8 @@ require 'open-uri'
...
@@ -6,8 +6,8 @@ require 'open-uri'
module
Pod
module
Pod
class
Dependency
<
Gem
::
Dependency
class
Dependency
<
Gem
::
Dependency
attr_reader
:external_source
,
:
bleeding
attr_reader
:external_source
,
:
head
alias
:
bleeding?
:bleeding
alias
:
head?
:head
attr_accessor
:specification
attr_accessor
:specification
def
initialize
(
*
name_and_version_requirements
,
&
block
)
def
initialize
(
*
name_and_version_requirements
,
&
block
)
...
@@ -19,22 +19,28 @@ module Pod
...
@@ -19,22 +19,28 @@ module Pod
elsif
!
name_and_version_requirements
.
empty?
&&
block
.
nil?
elsif
!
name_and_version_requirements
.
empty?
&&
block
.
nil?
if
name_and_version_requirements
.
last
.
is_a?
(
Hash
)
if
name_and_version_requirements
.
last
.
is_a?
(
Hash
)
@external_source
=
ExternalSources
.
from_params
(
name_and_version_requirements
[
0
].
split
(
'/'
).
first
,
name_and_version_requirements
.
pop
)
@external_source
=
ExternalSources
.
from_params
(
name_and_version_requirements
[
0
].
split
(
'/'
).
first
,
name_and_version_requirements
.
pop
)
elsif
name_and_version_requirements
.
last
.
is_a?
(
Symbol
)
symbol
=
name_and_version_requirements
.
pop
elsif
(
symbol
=
name_and_version_requirements
.
last
).
is_a?
(
Symbol
)
&&
symbol
==
:head
if
symbol
==
:bleeding
name_and_version_requirements
.
pop
@bleeding
=
true
@head
=
true
else
raise
Informative
,
"Unrecognized symbol `
#{
symbol
}
' for dependency `
#{
name_and_version_requirements
[
0
]
}
'"
end
end
end
super
(
*
name_and_version_requirements
)
super
(
*
name_and_version_requirements
)
if
head?
&&
!
latest_version?
raise
Informative
,
"A `:head' dependency may not specify version requirements."
end
else
else
raise
Informative
,
"A dependency needs either a name and version requirements, "
\
raise
Informative
,
"A dependency needs either a name and version requirements, "
\
"a source hash, or a block which defines a podspec."
"a source hash, or a block which defines a podspec."
end
end
end
end
def
latest_version?
versions
=
@version_requirements
.
requirements
.
map
(
&
:last
)
versions
==
[
Gem
::
Version
.
new
(
'0'
)]
end
def
==
(
other
)
def
==
(
other
)
super
&&
(
@specification
?
@specification
==
other
.
specification
:
@external_source
==
other
.
external_source
)
super
&&
(
@specification
?
@specification
==
other
.
specification
:
@external_source
==
other
.
external_source
)
end
end
...
@@ -76,9 +82,9 @@ module Pod
...
@@ -76,9 +82,9 @@ module Pod
elsif
@version_requirements
!=
Gem
::
Requirement
.
default
elsif
@version_requirements
!=
Gem
::
Requirement
.
default
version
<<
@version_requirements
.
to_s
version
<<
@version_requirements
.
to_s
end
end
result
=
@name
result
=
@name
.
dup
result
=
result
+
" (
#{
version
}
)"
unless
version
.
empty?
result
+=
" (
#{
version
}
)"
unless
version
.
empty?
result
=
result
+
" [BLEEDING]"
if
bleeding
?
result
+=
" [HEAD]"
if
head
?
result
result
end
end
...
...
lib/cocoapods/downloader/git.rb
View file @
f88e26c1
...
@@ -23,7 +23,7 @@ module Pod
...
@@ -23,7 +23,7 @@ module Pod
else
else
download_head
download_head
end
end
removed_cached_repos_if_needed
prune_cache
end
end
def
create_cache
def
create_cache
...
@@ -33,7 +33,7 @@ module Pod
...
@@ -33,7 +33,7 @@ module Pod
clone
(
url
,
cache_path
)
clone
(
url
,
cache_path
)
end
end
def
removed_cached_repos_if_needed
def
prune_cache
return
unless
caches_dir
.
exist?
return
unless
caches_dir
.
exist?
Dir
.
chdir
(
caches_dir
)
do
Dir
.
chdir
(
caches_dir
)
do
repos
=
Pathname
.
new
(
caches_dir
).
children
.
select
{
|
c
|
c
.
directory?
}.
sort_by
(
&
:ctime
)
repos
=
Pathname
.
new
(
caches_dir
).
children
.
select
{
|
c
|
c
.
directory?
}.
sort_by
(
&
:ctime
)
...
...
lib/cocoapods/installer.rb
View file @
f88e26c1
...
@@ -48,18 +48,17 @@ module Pod
...
@@ -48,18 +48,17 @@ module Pod
pods
.
each
do
|
pod
|
pods
.
each
do
|
pod
|
unless
config
.
silent?
unless
config
.
silent?
marker
=
config
.
verbose
?
"
\n
-> "
.
green
:
''
marker
=
config
.
verbose
?
"
\n
-> "
.
green
:
''
if
pod
.
top_specification
.
preferred_dependency
if
subspec_name
=
pod
.
top_specification
.
preferred_dependency
name
=
"
#{
pod
.
top_specification
.
name
}
/
#{
pod
.
top_specification
.
preferred_dependency
}
(
#{
pod
.
top_specification
.
version
}
)"
name
=
"
#{
pod
.
top_specification
.
name
}
/
#{
subspec_name
}
(
#{
pod
.
top_specification
.
version
}
)"
name
<<
"[BLEEDING]"
if
pod
.
top_specification
.
bleeding?
else
else
name
=
pod
.
to_s
name
=
pod
.
to_s
end
end
name
<<
" [HEAD]"
if
pod
.
top_specification
.
version
.
head?
puts
marker
<<
(
pod
.
exists?
?
"Using
#{
name
}
"
:
"Installing
#{
name
}
"
.
green
)
puts
marker
<<
(
pod
.
exists?
?
"Using
#{
name
}
"
:
"Installing
#{
name
}
"
.
green
)
end
end
unless
pod
.
exists?
unless
pod
.
exists?
downloader
=
Downloader
.
for_pod
(
pod
)
download_pod
(
pod
)
downloader
.
download
# The docs need to be generated before cleaning because
# The docs need to be generated before cleaning because
# the documentation is created for all the subspecs.
# the documentation is created for all the subspecs.
generate_docs
(
pod
)
generate_docs
(
pod
)
...
@@ -68,6 +67,19 @@ module Pod
...
@@ -68,6 +67,19 @@ module Pod
end
end
end
end
def
download_pod
(
pod
)
downloader
=
Downloader
.
for_pod
(
pod
)
# Force the `bleeding edge' version if necessary.
if
pod
.
top_specification
.
version
.
head?
if
downloader
.
respond_to?
(
:download_head
)
downloader
.
download_head
else
end
else
downloader
.
download
end
end
#TODO: move to generator ?
#TODO: move to generator ?
def
generate_docs
(
pod
)
def
generate_docs
(
pod
)
doc_generator
=
Generator
::
Documentation
.
new
(
pod
)
doc_generator
=
Generator
::
Documentation
.
new
(
pod
)
...
...
lib/cocoapods/resolver.rb
View file @
f88e26c1
...
@@ -64,8 +64,9 @@ module Pod
...
@@ -64,8 +64,9 @@ module Pod
spec
=
set
.
specification_by_name
(
dependency
.
name
)
spec
=
set
.
specification_by_name
(
dependency
.
name
)
@loaded_specs
<<
spec
.
name
@loaded_specs
<<
spec
.
name
@specs
[
spec
.
name
]
=
spec
@specs
[
spec
.
name
]
=
spec
# Configure the specification
spec
.
activate_platform
(
target_definition
.
platform
)
spec
.
activate_platform
(
target_definition
.
platform
)
spec
.
bleeding
=
dependency
.
bleeding
?
spec
.
version
.
head
=
dependency
.
head
?
# And recursively load the dependencies of the spec.
# And recursively load the dependencies of the spec.
find_dependency_specs
(
spec
,
spec
.
dependencies
,
target_definition
)
if
spec
.
dependencies
find_dependency_specs
(
spec
,
spec
.
dependencies
,
target_definition
)
if
spec
.
dependencies
end
end
...
...
lib/cocoapods/specification.rb
View file @
f88e26c1
...
@@ -180,14 +180,6 @@ module Pod
...
@@ -180,14 +180,6 @@ module Pod
@platform
=
Platform
.
new
(
*
platform
)
@platform
=
Platform
.
new
(
*
platform
)
end
end
# @!method bleeding
#
# @return [BOOL] returns wheter the specification is in bleeding mode.
#
attr_accessor
:bleeding
alias_method
:bleeding?
,
:bleeding
# If not platform is specified all the platforms are returned.
# If not platform is specified all the platforms are returned.
def
available_platforms
def
available_platforms
platform
.
nil?
?
@define_for_platforms
.
map
{
|
platform
|
Platform
.
new
(
platform
,
deployment_target
(
platform
))
}
:
[
platform
]
platform
.
nil?
?
@define_for_platforms
.
map
{
|
platform
|
Platform
.
new
(
platform
,
deployment_target
(
platform
))
}
:
[
platform
]
...
@@ -196,6 +188,7 @@ module Pod
...
@@ -196,6 +188,7 @@ module Pod
### Top level attributes. These attributes represent the unique features of pod and can't be specified by subspecs.
### Top level attributes. These attributes represent the unique features of pod and can't be specified by subspecs.
top_attr_accessor
:defined_in_file
top_attr_accessor
:defined_in_file
top_attr_accessor
:source
top_attr_accessor
:homepage
top_attr_accessor
:homepage
top_attr_accessor
:summary
top_attr_accessor
:summary
top_attr_accessor
:documentation
top_attr_accessor
:documentation
...
@@ -205,23 +198,6 @@ module Pod
...
@@ -205,23 +198,6 @@ module Pod
top_attr_reader
:description
,
lambda
{
|
instance
,
ivar
|
ivar
||
instance
.
summary
}
top_attr_reader
:description
,
lambda
{
|
instance
,
ivar
|
ivar
||
instance
.
summary
}
top_attr_writer
:description
,
lambda
{
|
d
|
d
.
strip_heredoc
}
top_attr_writer
:description
,
lambda
{
|
d
|
d
.
strip_heredoc
}
# @!method source
#
# @abstract
# Returns the source of the pod. If the specification is set in bleeding mode
# and the source is a git repository the head of master will be returned.
#
top_attr_writer
:source
top_attr_reader
:source
,
lambda
{
|
instance
,
ivar
|
if
instance
.
bleeding?
raise
Informative
,
'Bleeding is supported only for git repos'
unless
ivar
[
:git
]
{
:git
=>
ivar
[
:git
]
}
else
ivar
end
}
# @!method license
# @!method license
#
#
# @abstract
# @abstract
...
@@ -374,15 +350,14 @@ module Pod
...
@@ -374,15 +350,14 @@ module Pod
attr_reader
:subspecs
attr_reader
:subspecs
def
recursive_subspecs
def
recursive_subspecs
unless
@recursive_subspecs
@recursive_subspecs
||=
begin
mapper
=
lambda
do
|
spec
|
mapper
=
lambda
do
|
spec
|
spec
.
subspecs
.
map
do
|
subspec
|
spec
.
subspecs
.
map
do
|
subspec
|
[
subspec
,
*
mapper
.
call
(
subspec
)]
[
subspec
,
*
mapper
.
call
(
subspec
)]
end
.
flatten
end
.
flatten
end
end
@recursive_subspecs
=
mapper
.
call
self
mapper
.
call
(
self
)
end
end
@recursive_subspecs
end
end
def
subspec_by_name
(
name
)
def
subspec_by_name
(
name
)
...
@@ -463,9 +438,7 @@ module Pod
...
@@ -463,9 +438,7 @@ module Pod
end
end
def
to_s
def
to_s
result
=
"
#{
name
}
(
#{
version
}
)"
"
#{
name
}
(
#{
version
}
)"
result
<<
" [BLEEDING]"
if
bleeding?
result
end
end
def
inspect
def
inspect
...
...
lib/cocoapods/version.rb
View file @
f88e26c1
...
@@ -4,6 +4,8 @@ require 'rubygems/version'
...
@@ -4,6 +4,8 @@ require 'rubygems/version'
module
Pod
module
Pod
class
Version
<
Gem
::
Version
class
Version
<
Gem
::
Version
attr_accessor
:head
alias_method
:head?
,
:head
end
end
end
end
spec/functional/downloader_spec.rb
View file @
f88e26c1
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
describe
"Pod::Downloader"
do
module
Pod
describe
"Downloader"
do
before
do
before
do
@pod
=
Pod
::
LocalPod
.
new
(
fixture_spec
(
'banana-lib/BananaLib.podspec'
),
temporary_sandbox
,
Pod
::
Platform
.
ios
)
@pod
=
LocalPod
.
new
(
fixture_spec
(
'banana-lib/BananaLib.podspec'
),
temporary_sandbox
,
Platform
.
ios
)
end
end
describe
"for Git"
do
describe
"for Git"
do
...
@@ -12,7 +13,7 @@ describe "Pod::Downloader" do
...
@@ -12,7 +13,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'fd56054'
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'fd56054'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
download
downloader
.
download
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'first commit'
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'first commit'
...
@@ -22,7 +23,7 @@ describe "Pod::Downloader" do
...
@@ -22,7 +23,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
fixture
(
'banana-lib'
),
:branch
=>
'topicbranch'
:git
=>
fixture
(
'banana-lib'
),
:branch
=>
'topicbranch'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
download
downloader
.
download
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'topicbranch'
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'topicbranch'
...
@@ -32,7 +33,7 @@ describe "Pod::Downloader" do
...
@@ -32,7 +33,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
fixture
(
'banana-lib'
),
:tag
=>
'v1.0'
:git
=>
fixture
(
'banana-lib'
),
:tag
=>
'v1.0'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
download
downloader
.
download
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'v1.0'
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'v1.0'
...
@@ -42,7 +43,7 @@ describe "Pod::Downloader" do
...
@@ -42,7 +43,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'fd56054'
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'fd56054'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
cache_path
.
rmtree
if
downloader
.
cache_path
.
exist?
downloader
.
cache_path
.
rmtree
if
downloader
.
cache_path
.
exist?
downloader
.
expects
(
:create_cache
).
once
downloader
.
expects
(
:create_cache
).
once
downloader
.
stubs
(
:download_commit
)
downloader
.
stubs
(
:download_commit
)
...
@@ -53,46 +54,46 @@ describe "Pod::Downloader" do
...
@@ -53,46 +54,46 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'fd56054'
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'fd56054'
)
)
original_chace_size
=
Pod
::
Downloader
::
Git
::
MAX_CACHE_SIZE
original_chace_size
=
Downloader
::
Git
::
MAX_CACHE_SIZE
Pod
::
Downloader
::
Git
.
__send__
(
:remove_const
,
'MAX_CACHE_SIZE'
)
Downloader
::
Git
.
__send__
(
:remove_const
,
'MAX_CACHE_SIZE'
)
Pod
::
Downloader
::
Git
::
MAX_CACHE_SIZE
=
0
Downloader
::
Git
::
MAX_CACHE_SIZE
=
0
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
stubs
(
:cache_dir
).
returns
(
temporary_directory
)
downloader
.
stubs
(
:cache_dir
).
returns
(
temporary_directory
)
downloader
.
download
downloader
.
download
downloader
.
cache_path
.
should
.
not
.
exist?
downloader
.
cache_path
.
should
.
not
.
exist?
Pod
::
Downloader
::
Git
.
__send__
(
:remove_const
,
'MAX_CACHE_SIZE'
)
Downloader
::
Git
.
__send__
(
:remove_const
,
'MAX_CACHE_SIZE'
)
Pod
::
Downloader
::
Git
::
MAX_CACHE_SIZE
=
original_chace_size
Downloader
::
Git
::
MAX_CACHE_SIZE
=
original_chace_size
end
end
xit
"raises if it can't find the url"
do
xit
"raises if it can't find the url"
do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
'find_me_if_you_can'
:git
=>
'find_me_if_you_can'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
lambda
{
downloader
.
download
}.
should
.
raise
Pod
::
Informative
lambda
{
downloader
.
download
}.
should
.
raise
Informative
end
end
it
"raises if it can't find a commit"
do
it
"raises if it can't find a commit"
do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'aaaaaa'
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'aaaaaa'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
lambda
{
downloader
.
download
}.
should
.
raise
Pod
::
Informative
lambda
{
downloader
.
download
}.
should
.
raise
Informative
end
end
it
"raises if it can't find a tag"
do
it
"raises if it can't find a tag"
do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
fixture
(
'banana-lib'
),
:tag
=>
'aaaaaa'
:git
=>
fixture
(
'banana-lib'
),
:tag
=>
'aaaaaa'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
lambda
{
downloader
.
download
}.
should
.
raise
Pod
::
Informative
lambda
{
downloader
.
download
}.
should
.
raise
Informative
end
end
it
"does not raise if it can find the reference"
do
it
"does not raise if it can find the reference"
do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'fd56054'
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'fd56054'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
lambda
{
downloader
.
download
}.
should
.
not
.
raise
lambda
{
downloader
.
download
}.
should
.
not
.
raise
end
end
...
@@ -100,7 +101,7 @@ describe "Pod::Downloader" do
...
@@ -100,7 +101,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'fd56054'
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'fd56054'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
clone_url
.
to_s
.
should
.
match
/Library\/Caches\/CocoaPods\/Git/
downloader
.
clone_url
.
to_s
.
should
.
match
/Library\/Caches\/CocoaPods\/Git/
end
end
...
@@ -108,7 +109,7 @@ describe "Pod::Downloader" do
...
@@ -108,7 +109,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
fixture
(
'banana-lib'
)
:git
=>
fixture
(
'banana-lib'
)
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
expects
(
:update_cache
).
once
downloader
.
expects
(
:update_cache
).
once
downloader
.
download
downloader
.
download
end
end
...
@@ -121,7 +122,7 @@ describe "Pod::Downloader" do
...
@@ -121,7 +122,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
tmp_repo_path
,
:commit
=>
'fd56054'
:git
=>
tmp_repo_path
,
:commit
=>
'fd56054'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
download
downloader
.
download
# make a new commit in the origin
# make a new commit in the origin
...
@@ -134,11 +135,11 @@ describe "Pod::Downloader" do
...
@@ -134,11 +135,11 @@ describe "Pod::Downloader" do
end
end
# require the new commit
# require the new commit
pod
=
Pod
::
LocalPod
.
new
(
fixture_spec
(
'banana-lib/BananaLib.podspec'
),
temporary_sandbox
,
Pod
::
Platform
.
ios
)
pod
=
LocalPod
.
new
(
fixture_spec
(
'banana-lib/BananaLib.podspec'
),
temporary_sandbox
,
Platform
.
ios
)
pod
.
top_specification
.
stubs
(
:source
).
returns
(
pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
tmp_repo_path
,
:commit
=>
commit
:git
=>
tmp_repo_path
,
:commit
=>
commit
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
pod
)
downloader
=
Downloader
.
for_pod
(
pod
)
downloader
.
download
downloader
.
download
(
pod
.
root
+
'test.txt'
).
should
.
exist?
(
pod
.
root
+
'test.txt'
).
should
.
exist?
end
end
...
@@ -147,7 +148,7 @@ describe "Pod::Downloader" do
...
@@ -147,7 +148,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'fd56054'
:git
=>
fixture
(
'banana-lib'
),
:commit
=>
'fd56054'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
download
downloader
.
download
downloader
.
expects
(
:update_cache
).
never
downloader
.
expects
(
:update_cache
).
never
downloader
.
download
downloader
.
download
...
@@ -161,7 +162,7 @@ describe "Pod::Downloader" do
...
@@ -161,7 +162,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
"git://github.com/lukeredpath/libPusher.git"
,
:download_only
=>
true
:git
=>
"git://github.com/lukeredpath/libPusher.git"
,
:download_only
=>
true
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
VCR
.
use_cassette
(
'tarballs'
,
:record
=>
:new_episodes
)
{
downloader
.
download
}
VCR
.
use_cassette
(
'tarballs'
,
:record
=>
:new_episodes
)
{
downloader
.
download
}
...
@@ -173,7 +174,7 @@ describe "Pod::Downloader" do
...
@@ -173,7 +174,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
"git://github.com/lukeredpath/libPusher.git"
,
:tag
=>
'v1.1'
,
:download_only
=>
true
:git
=>
"git://github.com/lukeredpath/libPusher.git"
,
:tag
=>
'v1.1'
,
:download_only
=>
true
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
VCR
.
use_cassette
(
'tarballs'
,
:record
=>
:new_episodes
)
{
downloader
.
download
}
VCR
.
use_cassette
(
'tarballs'
,
:record
=>
:new_episodes
)
{
downloader
.
download
}
...
@@ -185,7 +186,7 @@ describe "Pod::Downloader" do
...
@@ -185,7 +186,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
"git://github.com/lukeredpath/libPusher.git"
,
:branch
=>
'gh-pages'
,
:download_only
=>
true
:git
=>
"git://github.com/lukeredpath/libPusher.git"
,
:branch
=>
'gh-pages'
,
:download_only
=>
true
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
VCR
.
use_cassette
(
'tarballs'
,
:record
=>
:new_episodes
)
{
downloader
.
download
}
VCR
.
use_cassette
(
'tarballs'
,
:record
=>
:new_episodes
)
{
downloader
.
download
}
...
@@ -198,7 +199,7 @@ describe "Pod::Downloader" do
...
@@ -198,7 +199,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
"git://github.com/lukeredpath/libPusher.git"
,
:commit
=>
'eca89998d5'
,
:download_only
=>
true
:git
=>
"git://github.com/lukeredpath/libPusher.git"
,
:commit
=>
'eca89998d5'
,
:download_only
=>
true
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
VCR
.
use_cassette
(
'tarballs'
,
:record
=>
:new_episodes
)
{
downloader
.
download
}
VCR
.
use_cassette
(
'tarballs'
,
:record
=>
:new_episodes
)
{
downloader
.
download
}
...
@@ -212,7 +213,7 @@ describe "Pod::Downloader" do
...
@@ -212,7 +213,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:hg
=>
fixture
(
'mercurial-repo'
),
:revision
=>
'46198bb3af96'
:hg
=>
fixture
(
'mercurial-repo'
),
:revision
=>
'46198bb3af96'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
download
downloader
.
download
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'first commit'
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'first commit'
end
end
...
@@ -223,7 +224,7 @@ describe "Pod::Downloader" do
...
@@ -223,7 +224,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:svn
=>
"file://
#{
fixture
(
'subversion-repo'
)
}
"
,
:revision
=>
'1'
:svn
=>
"file://
#{
fixture
(
'subversion-repo'
)
}
"
,
:revision
=>
'1'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
download
downloader
.
download
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'first commit'
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'first commit'
end
end
...
@@ -232,7 +233,7 @@ describe "Pod::Downloader" do
...
@@ -232,7 +233,7 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:svn
=>
"file://
#{
fixture
(
'subversion-repo'
)
}
/tags/tag-1"
:svn
=>
"file://
#{
fixture
(
'subversion-repo'
)
}
/tags/tag-1"
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
downloader
.
download
downloader
.
download
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'tag 1'
(
@pod
.
root
+
'README'
).
read
.
strip
.
should
==
'tag 1'
end
end
...
@@ -245,11 +246,12 @@ describe "Pod::Downloader" do
...
@@ -245,11 +246,12 @@ describe "Pod::Downloader" do
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
@pod
.
top_specification
.
stubs
(
:source
).
returns
(
:http
=>
'http://dl.google.com/googleadmobadssdk/googleadmobsearchadssdkios.zip'
:http
=>
'http://dl.google.com/googleadmobadssdk/googleadmobsearchadssdkios.zip'
)
)
downloader
=
Pod
::
Downloader
.
for_pod
(
@pod
)
downloader
=
Downloader
.
for_pod
(
@pod
)
VCR
.
use_cassette
(
'tarballs'
,
:record
=>
:new_episodes
)
{
downloader
.
download
}
VCR
.
use_cassette
(
'tarballs'
,
:record
=>
:new_episodes
)
{
downloader
.
download
}
(
@pod
.
root
+
'GoogleAdMobSearchAdsSDK/GADSearchRequest.h'
).
should
.
exist
(
@pod
.
root
+
'GoogleAdMobSearchAdsSDK/GADSearchRequest.h'
).
should
.
exist
(
@pod
.
root
+
'GoogleAdMobSearchAdsSDK/GADSearchRequest.h'
).
read
.
strip
.
should
=~
/Google Search Ads iOS SDK/
(
@pod
.
root
+
'GoogleAdMobSearchAdsSDK/GADSearchRequest.h'
).
read
.
strip
.
should
=~
/Google Search Ads iOS SDK/
end
end
end
end
end
end
end
spec/unit/dependency_spec.rb
View file @
f88e26c1
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
describe
"Pod::Dependency"
do
module
Pod
describe
Dependency
do
it
"merges dependencies (taken from newer RubyGems version)"
do
it
"merges dependencies (taken from newer RubyGems version)"
do
dep1
=
Pod
::
Dependency
.
new
(
'bananas'
,
'>= 1.8'
)
dep1
=
Dependency
.
new
(
'bananas'
,
'>= 1.8'
)
dep2
=
Pod
::
Dependency
.
new
(
'bananas'
,
'1.9'
)
dep2
=
Dependency
.
new
(
'bananas'
,
'1.9'
)
dep1
.
merge
(
dep2
).
should
==
Pod
::
Dependency
.
new
(
'bananas'
,
'>= 1.8'
,
'1.9'
)
dep1
.
merge
(
dep2
).
should
==
Dependency
.
new
(
'bananas'
,
'>= 1.8'
,
'1.9'
)
end
end
it
"returns the name of the dependency, or the name of the pod of which this is a subspec"
do
it
"returns the name of the dependency, or the name of the pod of which this is a subspec"
do
dep
=
Pod
::
Dependency
.
new
(
'RestKit'
)
dep
=
Dependency
.
new
(
'RestKit'
)
dep
.
top_level_spec_name
.
should
==
'RestKit'
dep
.
top_level_spec_name
.
should
==
'RestKit'
dep
=
Pod
::
Dependency
.
new
(
'RestKit/Networking'
)
dep
=
Dependency
.
new
(
'RestKit/Networking'
)
dep
.
top_level_spec_name
.
should
==
'RestKit'
dep
.
top_level_spec_name
.
should
==
'RestKit'
end
end
it
"returns a copy of the dependency but for the top level spec, if it's a subspec"
do
it
"returns a copy of the dependency but for the top level spec, if it's a subspec"
do
dep
=
Pod
::
Dependency
.
new
(
'RestKit'
,
'>= 1.2.3'
)
dep
=
Dependency
.
new
(
'RestKit'
,
'>= 1.2.3'
)
dep
.
to_top_level_spec_dependency
.
should
==
Pod
::
Dependency
.
new
(
'RestKit'
,
'>= 1.2.3'
)
dep
.
to_top_level_spec_dependency
.
should
==
Dependency
.
new
(
'RestKit'
,
'>= 1.2.3'
)
dep
=
Pod
::
Dependency
.
new
(
'RestKit/Networking'
,
'>= 1.2.3'
)
dep
=
Dependency
.
new
(
'RestKit/Networking'
,
'>= 1.2.3'
)
dep
.
to_top_level_spec_dependency
.
should
==
Pod
::
Dependency
.
new
(
'RestKit'
,
'>= 1.2.3'
)
dep
.
to_top_level_spec_dependency
.
should
==
Dependency
.
new
(
'RestKit'
,
'>= 1.2.3'
)
end
end
it
"is equal to another dependency if `external_source' is the same"
do
it
"is equal to another dependency if `external_source' is the same"
do
dep1
=
Pod
::
Dependency
.
new
(
'bananas'
,
:git
=>
'GIT-URL'
)
dep1
=
Dependency
.
new
(
'bananas'
,
:git
=>
'GIT-URL'
)
dep2
=
Pod
::
Dependency
.
new
(
'bananas'
)
dep2
=
Dependency
.
new
(
'bananas'
)
dep1
.
should
.
not
==
dep2
dep1
.
should
.
not
==
dep2
dep3
=
Pod
::
Dependency
.
new
(
'bananas'
,
:git
=>
'GIT-URL'
)
dep3
=
Dependency
.
new
(
'bananas'
,
:git
=>
'GIT-URL'
)
dep1
.
should
==
dep3
dep1
.
should
==
dep3
end
end
it
"is equal to another dependency if `specification' is equal"
do
it
"is equal to another dependency if `specification' is equal"
do
dep1
=
Pod
::
Dependency
.
new
{
|
s
|
s
.
name
=
'bananas'
;
s
.
version
=
'1'
}
dep1
=
Dependency
.
new
{
|
s
|
s
.
name
=
'bananas'
;
s
.
version
=
'1'
}
dep2
=
Pod
::
Dependency
.
new
(
'bananas'
)
dep2
=
Dependency
.
new
(
'bananas'
)
dep1
.
should
.
not
==
dep2
dep1
.
should
.
not
==
dep2
dep2
=
Pod
::
Dependency
.
new
{
|
s
|
s
.
name
=
'bananas'
;
s
.
version
=
'1'
}
dep2
=
Dependency
.
new
{
|
s
|
s
.
name
=
'bananas'
;
s
.
version
=
'1'
}
dep1
.
should
==
dep2
dep1
.
should
==
dep2
end
end
it
'raises if created without either valid name/version/external requirements or a block'
do
it
'raises if created without either valid name/version/external requirements or a block'
do
lambda
{
Pod
::
Dependency
.
new
}.
should
.
raise
Pod
::
Informative
lambda
{
Dependency
.
new
}.
should
.
raise
Informative
end
end
end
describe
"Pod::Dependency"
,
"defined with a block"
do
describe
"defined with a block"
do
before
do
before
do
@dependency
=
Pod
::
Dependency
.
new
do
|
spec
|
@dependency
=
Dependency
.
new
do
|
spec
|
spec
.
name
=
"my-custom-spec"
spec
.
name
=
"my-custom-spec"
spec
.
version
=
"1.0.3"
spec
.
version
=
"1.0.3"
end
end
...
@@ -57,14 +57,36 @@ describe "Pod::Dependency", "defined with a block" do
...
@@ -57,14 +57,36 @@ describe "Pod::Dependency", "defined with a block" do
it
'attaches a custom spec to the dependency, configured by the block'
do
it
'attaches a custom spec to the dependency, configured by the block'
do
@dependency
.
specification
.
name
.
should
==
"my-custom-spec"
@dependency
.
specification
.
name
.
should
==
"my-custom-spec"
end
end
end
end
describe
"Pod::Dependency"
,
"with a hash of external source settings"
do
describe
"with a hash of external source settings"
do
before
do
before
do
@dependency
=
Pod
::
Dependency
.
new
(
"cocoapods"
,
:git
=>
"git://github.com/cocoapods/cocoapods"
)
@dependency
=
Dependency
.
new
(
"cocoapods"
,
:git
=>
"git://github.com/cocoapods/cocoapods"
)
end
end
it
'it
identifies itself as an external dependency'
do
it
'
identifies itself as an external dependency'
do
@dependency
.
should
.
be
.
external
@dependency
.
should
.
be
.
external
end
end
end
describe
"with flags"
do
it
"identifies itself as a `bleeding edge' dependency"
do
dependency
=
Dependency
.
new
(
"cocoapods"
,
:head
)
dependency
.
should
.
be
.
head
dependency
.
to_s
.
should
==
"cocoapods [HEAD]"
end
it
"only supports the `:head' option on the last version of a pod"
do
should
.
raise
Informative
do
Dependency
.
new
(
"cocoapods"
,
"1.2.3"
,
:head
)
end
end
it
"raises if an invalid flag is given"
do
should
.
raise
ArgumentError
do
Dependency
.
new
(
"cocoapods"
,
:foot
)
end
end
end
end
end
end
spec/unit/downloader_spec.rb
View file @
f88e26c1
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
def
stub_pod_with_source
(
source_options
)
def
stub_pod_with_source
(
source_options
)
specification
=
stub
(
specification
=
stub
(
:source
=>
source_options
)
:source
=>
source_options
)
stub
(
'pod'
)
do
stub
(
'pod'
)
do
stubs
(
:root
).
returns
(
temporary_sandbox
.
root
)
stubs
(
:root
).
returns
(
temporary_sandbox
.
root
)
stubs
(
:top_specification
).
returns
(
specification
)
stubs
(
:top_specification
).
returns
(
specification
)
end
end
end
end
describe
"Pod::Downloader"
do
module
Pod
describe
Downloader
do
it
"returns a git downloader with parsed options"
do
it
"returns a git downloader with parsed options"
do
pod
=
Pod
::
LocalPod
.
new
(
fixture_spec
(
'banana-lib/BananaLib.podspec'
),
temporary_sandbox
,
Pod
::
Platform
.
ios
)
pod
=
LocalPod
.
new
(
fixture_spec
(
'banana-lib/BananaLib.podspec'
),
temporary_sandbox
,
Platform
.
ios
)
downloader
=
Pod
::
Downloader
.
for_pod
(
pod
)
downloader
=
Downloader
.
for_pod
(
pod
)
downloader
.
should
.
be
.
instance_of
Pod
::
Downloader
::
Git
downloader
.
should
.
be
.
instance_of
Downloader
::
Git
downloader
.
url
.
should
==
'http://banana-corp.local/banana-lib.git'
downloader
.
url
.
should
==
'http://banana-corp.local/banana-lib.git'
downloader
.
options
.
should
==
{
:tag
=>
'v1.0'
}
downloader
.
options
.
should
==
{
:tag
=>
'v1.0'
}
end
end
it
'returns a github downloader when the :git URL is on github'
do
it
'returns a github downloader when the :git URL is on github'
do
pod
=
Pod
::
LocalPod
.
new
(
fixture_spec
(
'banana-lib/BananaLib.podspec'
),
temporary_sandbox
,
Pod
::
Platform
.
ios
)
pod
=
LocalPod
.
new
(
fixture_spec
(
'banana-lib/BananaLib.podspec'
),
temporary_sandbox
,
Platform
.
ios
)
pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
"git://github.com/CocoaPods/CocoaPods"
)
pod
.
top_specification
.
stubs
(
:source
).
returns
(
:git
=>
"git://github.com/CocoaPods/CocoaPods"
)
downloader
=
Pod
::
Downloader
.
for_pod
(
pod
)
downloader
=
Downloader
.
for_pod
(
pod
)
downloader
.
should
.
be
.
instance_of
Pod
::
Downloader
::
GitHub
downloader
.
should
.
be
.
instance_of
Downloader
::
GitHub
end
end
end
end
describe
Pod
::
Downloader
::
GitHub
do
describe
Downloader
::
GitHub
do
it
'can convert public HTTP repository URLs to the tarball URL'
do
it
'can convert public HTTP repository URLs to the tarball URL'
do
downloader
=
Pod
::
Downloader
.
for_pod
(
stub_pod_with_source
(
downloader
=
Downloader
.
for_pod
(
stub_pod_with_source
(
:git
=>
"https://github.com/CocoaPods/CocoaPods.git"
:git
=>
"https://github.com/CocoaPods/CocoaPods.git"
))
))
downloader
.
tarball_url_for
(
'master'
).
should
==
"https://github.com/CocoaPods/CocoaPods/tarball/master"
downloader
.
tarball_url_for
(
'master'
).
should
==
"https://github.com/CocoaPods/CocoaPods/tarball/master"
end
end
it
'can convert private HTTP repository URLs to the tarball URL'
do
it
'can convert private HTTP repository URLs to the tarball URL'
do
downloader
=
Pod
::
Downloader
.
for_pod
(
stub_pod_with_source
(
downloader
=
Downloader
.
for_pod
(
stub_pod_with_source
(
:git
=>
"https://lukeredpath@github.com/CocoaPods/CocoaPods.git"
:git
=>
"https://lukeredpath@github.com/CocoaPods/CocoaPods.git"
))
))
downloader
.
tarball_url_for
(
'master'
).
should
==
"https://github.com/CocoaPods/CocoaPods/tarball/master"
downloader
.
tarball_url_for
(
'master'
).
should
==
"https://github.com/CocoaPods/CocoaPods/tarball/master"
end
end
it
'can convert private SSH repository URLs to the tarball URL'
do
it
'can convert private SSH repository URLs to the tarball URL'
do
downloader
=
Pod
::
Downloader
.
for_pod
(
stub_pod_with_source
(
downloader
=
Downloader
.
for_pod
(
stub_pod_with_source
(
:git
=>
"git@github.com:CocoaPods/CocoaPods.git"
:git
=>
"git@github.com:CocoaPods/CocoaPods.git"
))
))
downloader
.
tarball_url_for
(
'master'
).
should
==
"https://github.com/CocoaPods/CocoaPods/tarball/master"
downloader
.
tarball_url_for
(
'master'
).
should
==
"https://github.com/CocoaPods/CocoaPods/tarball/master"
end
end
it
'can convert public git protocol repository URLs to the tarball URL'
do
it
'can convert public git protocol repository URLs to the tarball URL'
do
downloader
=
Pod
::
Downloader
.
for_pod
(
stub_pod_with_source
(
downloader
=
Downloader
.
for_pod
(
stub_pod_with_source
(
:git
=>
"git://github.com/CocoaPods/CocoaPods.git"
:git
=>
"git://github.com/CocoaPods/CocoaPods.git"
))
))
downloader
.
tarball_url_for
(
'master'
).
should
==
"https://github.com/CocoaPods/CocoaPods/tarball/master"
downloader
.
tarball_url_for
(
'master'
).
should
==
"https://github.com/CocoaPods/CocoaPods/tarball/master"
end
end
end
end
end
spec/unit/installer_spec.rb
View file @
f88e26c1
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
describe
"Pod::Installer"
do
module
Pod
describe
Installer
do
before
do
before
do
config
.
repos_dir
=
fixture
(
'spec-repos'
)
config
.
repos_dir
=
fixture
(
'spec-repos'
)
config
.
project_pods_root
=
fixture
(
'integration'
)
config
.
project_pods_root
=
fixture
(
'integration'
)
...
@@ -8,12 +9,12 @@ describe "Pod::Installer" do
...
@@ -8,12 +9,12 @@ describe "Pod::Installer" do
describe
"by default"
do
describe
"by default"
do
before
do
before
do
podfile
=
Pod
::
Podfile
.
new
do
podfile
=
Podfile
.
new
do
platform
:ios
platform
:ios
xcodeproj
'MyProject'
xcodeproj
'MyProject'
pod
'JSONKit'
pod
'JSONKit'
end
end
@xcconfig
=
Pod
::
Installer
.
new
(
podfile
).
target_installers
.
first
.
xcconfig
.
to_hash
@xcconfig
=
Installer
.
new
(
podfile
).
target_installers
.
first
.
xcconfig
.
to_hash
end
end
it
"sets the header search paths where installed Pod headers can be found"
do
it
"sets the header search paths where installed Pod headers can be found"
do
...
@@ -30,13 +31,13 @@ describe "Pod::Installer" do
...
@@ -30,13 +31,13 @@ describe "Pod::Installer" do
end
end
it
"generates a BridgeSupport metadata file from all the pod headers"
do
it
"generates a BridgeSupport metadata file from all the pod headers"
do
podfile
=
Pod
::
Podfile
.
new
do
podfile
=
Podfile
.
new
do
platform
:osx
platform
:osx
pod
'ASIHTTPRequest'
pod
'ASIHTTPRequest'
end
end
installer
=
Pod
::
Installer
.
new
(
podfile
)
installer
=
Installer
.
new
(
podfile
)
pods
=
installer
.
specifications
.
map
do
|
spec
|
pods
=
installer
.
specifications
.
map
do
|
spec
|
Pod
::
LocalPod
.
new
(
spec
,
installer
.
sandbox
,
podfile
.
target_definitions
[
:default
].
platform
)
LocalPod
.
new
(
spec
,
installer
.
sandbox
,
podfile
.
target_definitions
[
:default
].
platform
)
end
end
expected
=
pods
.
map
{
|
pod
|
pod
.
header_files
}.
flatten
.
map
{
|
header
|
config
.
project_pods_root
+
header
}
expected
=
pods
.
map
{
|
pod
|
pod
.
header_files
}.
flatten
.
map
{
|
header
|
config
.
project_pods_root
+
header
}
expected
.
size
.
should
>
0
expected
.
size
.
should
>
0
...
@@ -44,23 +45,39 @@ describe "Pod::Installer" do
...
@@ -44,23 +45,39 @@ describe "Pod::Installer" do
end
end
it
"omits empty target definitions"
do
it
"omits empty target definitions"
do
podfile
=
Pod
::
Podfile
.
new
do
podfile
=
Podfile
.
new
do
platform
:ios
platform
:ios
target
:not_empty
do
target
:not_empty
do
pod
'JSONKit'
pod
'JSONKit'
end
end
end
end
installer
=
Pod
::
Installer
.
new
(
podfile
)
installer
=
Installer
.
new
(
podfile
)
installer
.
target_installers
.
map
(
&
:target_definition
).
map
(
&
:name
).
should
==
[
:not_empty
]
installer
.
target_installers
.
map
(
&
:target_definition
).
map
(
&
:name
).
should
==
[
:not_empty
]
end
end
it
"adds the user's build configurations"
do
it
"adds the user's build configurations"
do
path
=
fixture
(
'SampleProject/SampleProject.xcodeproj'
)
path
=
fixture
(
'SampleProject/SampleProject.xcodeproj'
)
podfile
=
Pod
::
Podfile
.
new
do
podfile
=
Podfile
.
new
do
platform
:ios
platform
:ios
xcodeproj
path
,
'App Store'
=>
:release
xcodeproj
path
,
'App Store'
=>
:release
end
end
installer
=
Pod
::
Installer
.
new
(
podfile
)
installer
=
Installer
.
new
(
podfile
)
installer
.
project
.
build_configurations
.
map
(
&
:name
).
sort
.
should
==
[
'App Store'
,
'Debug'
,
'Release'
,
'Test'
]
installer
.
project
.
build_configurations
.
map
(
&
:name
).
sort
.
should
==
[
'App Store'
,
'Debug'
,
'Release'
,
'Test'
]
end
end
it
"forces downloading of the `bleeding edge' version of a pod"
do
podfile
=
Podfile
.
new
do
platform
:ios
pod
'JSONKit'
,
:head
end
installer
=
Installer
.
new
(
podfile
)
pod
=
installer
.
pods
.
first
downloader
=
stub
(
'Downloader'
)
Downloader
.
stubs
(
:for_pod
).
returns
(
downloader
)
downloader
.
expects
(
:download_head
)
installer
.
download_pod
(
pod
)
end
end
end
end
spec/unit/resolver_spec.rb
View file @
f88e26c1
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
describe
"Pod::Resolver"
do
module
Pod
describe
Resolver
do
before
do
before
do
config
.
repos_dir
=
fixture
(
'spec-repos'
)
config
.
repos_dir
=
fixture
(
'spec-repos'
)
@podfile
=
Pod
::
Podfile
.
new
do
@podfile
=
Podfile
.
new
do
platform
:ios
platform
:ios
pod
'BlocksKit'
pod
'BlocksKit'
# pod 'ASIWebPageRequest'
# pod 'ASIWebPageRequest'
end
end
@resolver
=
Pod
::
Resolver
.
new
(
@podfile
,
stub
(
'sandbox'
))
@resolver
=
Resolver
.
new
(
@podfile
,
stub
(
'sandbox'
))
end
end
it
"holds the context state, such as cached specification sets"
do
it
"holds the context state, such as cached specification sets"
do
@resolver
.
resolve
@resolver
.
resolve
@resolver
.
cached_sets
.
values
.
sort_by
(
&
:name
).
should
==
[
@resolver
.
cached_sets
.
values
.
sort_by
(
&
:name
).
should
==
[
Pod
::
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/A2DynamicDelegate'
),
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/A2DynamicDelegate'
),
Pod
::
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/BlocksKit'
),
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/BlocksKit'
),
Pod
::
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/libffi'
),
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/libffi'
),
].
sort_by
(
&
:name
)
].
sort_by
(
&
:name
)
end
end
it
"returns all specs needed for the dependency"
do
it
"returns all specs needed for the dependency"
do
specs
=
@resolver
.
resolve
.
values
.
flatten
specs
=
@resolver
.
resolve
.
values
.
flatten
specs
.
map
(
&
:class
).
uniq
.
should
==
[
Pod
::
Specification
]
specs
.
map
(
&
:class
).
uniq
.
should
==
[
Specification
]
specs
.
map
(
&
:name
).
sort
.
should
==
%w{ A2DynamicDelegate BlocksKit libffi }
specs
.
map
(
&
:name
).
sort
.
should
==
%w{ A2DynamicDelegate BlocksKit libffi }
end
end
...
@@ -35,7 +36,7 @@ describe "Pod::Resolver" do
...
@@ -35,7 +36,7 @@ describe "Pod::Resolver" do
end
end
it
"raises once any of the dependencies does not match the platform of its podfile target"
do
it
"raises once any of the dependencies does not match the platform of its podfile target"
do
set
=
Pod
::
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/BlocksKit'
)
set
=
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/BlocksKit'
)
@resolver
.
cached_sets
[
'BlocksKit'
]
=
set
@resolver
.
cached_sets
[
'BlocksKit'
]
=
set
def
set
.
stub_platform
=
(
platform
);
@stubbed_platform
=
platform
;
end
def
set
.
stub_platform
=
(
platform
);
@stubbed_platform
=
platform
;
end
...
@@ -45,34 +46,34 @@ describe "Pod::Resolver" do
...
@@ -45,34 +46,34 @@ describe "Pod::Resolver" do
set
.
stub_platform
=
:ios
set
.
stub_platform
=
:ios
lambda
{
@resolver
.
resolve
}.
should
.
not
.
raise
lambda
{
@resolver
.
resolve
}.
should
.
not
.
raise
set
.
stub_platform
=
:osx
set
.
stub_platform
=
:osx
lambda
{
@resolver
.
resolve
}.
should
.
raise
Pod
::
Informative
lambda
{
@resolver
.
resolve
}.
should
.
raise
Informative
@podfile
.
platform
:osx
@podfile
.
platform
:osx
set
.
stub_platform
=
:osx
set
.
stub_platform
=
:osx
lambda
{
@resolver
.
resolve
}.
should
.
not
.
raise
lambda
{
@resolver
.
resolve
}.
should
.
not
.
raise
set
.
stub_platform
=
:ios
set
.
stub_platform
=
:ios
lambda
{
@resolver
.
resolve
}.
should
.
raise
Pod
::
Informative
lambda
{
@resolver
.
resolve
}.
should
.
raise
Informative
end
end
it
"raises once any of the dependencies does not have a deployment_target compatible with its podfile target"
do
it
"raises once any of the dependencies does not have a deployment_target compatible with its podfile target"
do
set
=
Pod
::
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/BlocksKit'
)
set
=
Spec
::
Set
.
new
(
config
.
repos_dir
+
'master/BlocksKit'
)
@resolver
.
cached_sets
[
'BlocksKit'
]
=
set
@resolver
.
cached_sets
[
'BlocksKit'
]
=
set
@podfile
.
platform
:ios
,
"4.0"
@podfile
.
platform
:ios
,
"4.0"
Pod
::
Specification
.
any_instance
.
stubs
(
:available_platforms
).
returns
([
Pod
::
Platform
.
new
(
:ios
,
'4.0'
),
Pod
::
Platform
.
new
(
:osx
,
'10.7'
)
])
Specification
.
any_instance
.
stubs
(
:available_platforms
).
returns
([
Platform
.
new
(
:ios
,
'4.0'
),
Platform
.
new
(
:osx
,
'10.7'
)
])
lambda
{
@resolver
.
resolve
}.
should
.
not
.
raise
lambda
{
@resolver
.
resolve
}.
should
.
not
.
raise
Pod
::
Specification
.
any_instance
.
stubs
(
:available_platforms
).
returns
([
Pod
::
Platform
.
new
(
:ios
,
'5.0'
),
Pod
::
Platform
.
new
(
:osx
,
'10.7'
)
])
Specification
.
any_instance
.
stubs
(
:available_platforms
).
returns
([
Platform
.
new
(
:ios
,
'5.0'
),
Platform
.
new
(
:osx
,
'10.7'
)
])
lambda
{
@resolver
.
resolve
}.
should
.
raise
Pod
::
Informative
lambda
{
@resolver
.
resolve
}.
should
.
raise
Informative
end
end
it
"resolves subspecs"
do
it
"resolves subspecs"
do
@podfile
=
Pod
::
Podfile
.
new
do
@podfile
=
Podfile
.
new
do
platform
:ios
platform
:ios
pod
'RestKit/Network'
pod
'RestKit/Network'
pod
'RestKit/ObjectMapping/XML'
pod
'RestKit/ObjectMapping/XML'
end
end
resolver
=
Pod
::
Resolver
.
new
(
@podfile
,
stub
(
'sandbox'
))
resolver
=
Resolver
.
new
(
@podfile
,
stub
(
'sandbox'
))
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:name
).
sort
.
should
==
%w{
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:name
).
sort
.
should
==
%w{
FileMD5Hash
FileMD5Hash
ISO8601DateFormatter
ISO8601DateFormatter
...
@@ -88,11 +89,11 @@ describe "Pod::Resolver" do
...
@@ -88,11 +89,11 @@ describe "Pod::Resolver" do
end
end
it
"includes all the subspecs of a specification node"
do
it
"includes all the subspecs of a specification node"
do
@podfile
=
Pod
::
Podfile
.
new
do
@podfile
=
Podfile
.
new
do
platform
:ios
platform
:ios
pod
'RestKit'
pod
'RestKit'
end
end
resolver
=
Pod
::
Resolver
.
new
(
@podfile
,
stub
(
'sandbox'
))
resolver
=
Resolver
.
new
(
@podfile
,
stub
(
'sandbox'
))
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:name
).
sort
.
should
==
%w{
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:name
).
sort
.
should
==
%w{
FileMD5Hash
FileMD5Hash
ISO8601DateFormatter
ISO8601DateFormatter
...
@@ -111,8 +112,8 @@ describe "Pod::Resolver" do
...
@@ -111,8 +112,8 @@ describe "Pod::Resolver" do
}
}
end
end
it
"if defined it includes only the main subspec of
of a specification node"
do
it
"it includes only the main subspec
of a specification node"
do
@podfile
=
Pod
::
Podfile
.
new
do
@podfile
=
Podfile
.
new
do
platform
:ios
platform
:ios
pod
do
|
s
|
pod
do
|
s
|
s
.
name
=
'RestKit'
s
.
name
=
'RestKit'
...
@@ -138,8 +139,10 @@ describe "Pod::Resolver" do
...
@@ -138,8 +139,10 @@ describe "Pod::Resolver" do
end
end
end
end
end
end
resolver
=
Pod
::
Resolver
.
new
(
@podfile
,
stub
(
'sandbox'
))
resolver
=
Resolver
.
new
(
@podfile
,
stub
(
'sandbox'
))
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:name
).
sort
.
should
==
%w{
specs
=
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:name
).
sort
specs
.
should
.
not
.
include
'RestKit/ObjectMapping/XML'
specs
.
should
==
%w{
LibComponentLogging-Core
LibComponentLogging-Core
LibComponentLogging-NSLog
LibComponentLogging-NSLog
RestKit
RestKit
...
@@ -149,13 +152,14 @@ describe "Pod::Resolver" do
...
@@ -149,13 +152,14 @@ describe "Pod::Resolver" do
RestKit/ObjectMapping/JSON
RestKit/ObjectMapping/JSON
RestKit/UI
RestKit/UI
}
}
end
it
"resolves subspecs with external constraints"
do
it
"resolves subspecs with external constraints"
do
@podfile
=
Pod
::
Pod
file
.
new
do
@podfile
=
Podfile
.
new
do
platform
:ios
platform
:ios
pod
'MainSpec/FirstSubSpec'
,
:git
=>
'GIT-URL'
pod
'MainSpec/FirstSubSpec'
,
:git
=>
'GIT-URL'
end
end
spec
=
Pod
::
Spec
.
new
do
|
s
|
spec
=
Spec
.
new
do
|
s
|
s
.
name
=
'MainSpec'
s
.
name
=
'MainSpec'
s
.
version
=
'1.2.3'
s
.
version
=
'1.2.3'
s
.
platform
=
:ios
s
.
platform
=
:ios
...
@@ -171,9 +175,20 @@ describe "Pod::Resolver" do
...
@@ -171,9 +175,20 @@ describe "Pod::Resolver" do
end
end
end
end
@podfile
.
dependencies
.
first
.
external_source
.
stubs
(
:specification_from_sandbox
).
returns
(
spec
)
@podfile
.
dependencies
.
first
.
external_source
.
stubs
(
:specification_from_sandbox
).
returns
(
spec
)
resolver
=
Pod
::
Resolver
.
new
(
@podfile
,
stub
(
'sandbox'
))
resolver
=
Resolver
.
new
(
@podfile
,
stub
(
'sandbox'
))
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:name
).
sort
.
should
==
%w{ MainSpec/FirstSubSpec MainSpec/FirstSubSpec/SecondSubSpec }
resolver
.
resolve
.
values
.
flatten
.
map
(
&
:name
).
sort
.
should
==
%w{ MainSpec/FirstSubSpec MainSpec/FirstSubSpec/SecondSubSpec }
end
end
it
"marks a specification's version to be a `bleeding edge' version"
do
podfile
=
Podfile
.
new
do
platform
:ios
pod
'FileMD5Hash'
pod
'JSONKit'
,
:head
end
resolver
=
Resolver
.
new
(
podfile
,
stub
(
'sandbox'
))
filemd5hash
,
jsonkit
=
resolver
.
resolve
.
values
.
first
.
sort_by
(
&
:name
)
filemd5hash
.
version
.
should
.
not
.
be
.
head
jsonkit
.
version
.
should
.
be
.
head
end
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