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
d6b73121
Commit
d6b73121
authored
Apr 16, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Downloader::Cache] Add specs for cached downloads
parent
dcc87e5e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
6 deletions
+37
-6
cache_spec.rb
spec/unit/downloader/cache_spec.rb
+37
-6
No files found.
spec/unit/downloader/cache_spec.rb
View file @
d6b73121
...
...
@@ -7,6 +7,7 @@ module Pod
@spec
=
fixture_spec
(
'banana-lib/BananaLib.podspec'
)
@spec
.
source
=
{
:git
=>
SpecHelper
.
fixture
(
'banana-lib'
)
}
@request
=
Downloader
::
Request
.
new
(
:spec
=>
@spec
,
:released
=>
true
)
@unreleased_request
=
Downloader
::
Request
.
new
(
:name
=>
'BananaLib'
,
:params
=>
@spec
.
source
)
@stub_download
=
lambda
do
|
cache
,
&
blk
|
cache
.
define_singleton_method
(
:download
)
do
|
name
,
target
,
params
,
head
|
FileUtils
.
mkdir_p
target
...
...
@@ -15,6 +16,10 @@ module Pod
end
end
after
do
@cache
.
root
.
rmtree
end
it
'returns the root'
do
@cache
.
root
.
should
.
be
.
directory?
end
...
...
@@ -31,7 +36,6 @@ module Pod
describe
'when downloading an un-released pod'
do
before
do
@request
=
Downloader
::
Request
.
new
(
:name
=>
'BananaLib'
,
:params
=>
@spec
.
source
)
@stub_download
.
call
@cache
do
File
.
open
(
'BananaLib.podspec.json'
,
'w'
)
{
|
f
|
f
<<
@spec
.
to_pretty_json
}
File
.
open
(
'OrangeLib.podspec.json'
,
'w'
)
{
|
f
|
f
<<
@spec
.
to_pretty_json
.
sub
(
/"name": "BananaLib"/
,
'"name": "OrangeLib"'
)
}
...
...
@@ -41,18 +45,45 @@ module Pod
it
'downloads the source'
do
@cache
.
expects
(
:copy_and_clean
).
twice
response
=
@cache
.
download_pod
(
@request
)
response
.
should
==
Downloader
::
Response
.
new
(
@cache
.
root
+
@request
.
slug
,
@spec
,
@spec
.
source
)
response
=
@cache
.
download_pod
(
@
unreleased_
request
)
response
.
should
==
Downloader
::
Response
.
new
(
@cache
.
root
+
@
unreleased_
request
.
slug
,
@spec
,
@spec
.
source
)
end
end
end
describe
'when the download is cached'
do
before
do
[
@request
,
@unreleased_request
].
each
do
|
request
|
path_for_spec
=
@cache
.
send
(
:path_for_spec
,
request
)
path_for_spec
.
dirname
.
mkpath
path_for_spec
.
open
(
'w'
)
{
|
f
|
f
<<
@spec
.
to_pretty_json
}
end
path_for_pod
=
@cache
.
send
(
:path_for_pod
,
request
)
path_for_pod
.
mkpath
Dir
.
chdir
(
path_for_pod
)
do
FileUtils
.
mkdir_p
'Classes'
File
.
open
(
'Classes/a.m'
,
'w'
)
{
}
end
end
end
after
do
@cache
.
root
.
rmtree
describe
'when downloading a released pod'
do
it
'does not download the source'
do
Downloader
::
Git
.
any_instance
.
expects
(
:download
).
never
@cache
.
expects
(
:uncached_pod
).
never
response
=
@cache
.
download_pod
(
@request
)
response
.
should
==
Downloader
::
Response
.
new
(
@cache
.
root
+
@request
.
slug
,
@spec
,
@spec
.
source
)
end
end
describe
'when downloading an unreleased pod'
do
it
'does not download the source'
do
Downloader
::
Git
.
any_instance
.
expects
(
:download
).
never
@cache
.
expects
(
:uncached_pod
).
never
response
=
@cache
.
download_pod
(
@unreleased_request
)
response
.
should
==
Downloader
::
Response
.
new
(
@cache
.
root
+
@unreleased_request
.
slug
,
@spec
,
@spec
.
source
)
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