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
5aef67a5
Commit
5aef67a5
authored
Jul 03, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Config] Spec robustness
parent
accc8726
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
44 deletions
+40
-44
config.rb
lib/cocoapods/config.rb
+2
-2
config_spec.rb
spec/unit/config_spec.rb
+38
-42
No files found.
lib/cocoapods/config.rb
View file @
5aef67a5
...
@@ -112,10 +112,10 @@ module Pod
...
@@ -112,10 +112,10 @@ module Pod
# @!group Initialization
# @!group Initialization
def
initialize
def
initialize
(
use_user_settings
=
true
)
configure_with
(
DEFAULTS
)
configure_with
(
DEFAULTS
)
if
user_settings_file
.
exist?
if
use
_user_settings
&&
use
r_settings_file
.
exist?
require
'yaml'
require
'yaml'
user_settings
=
YAML
.
load_file
(
user_settings_file
)
user_settings
=
YAML
.
load_file
(
user_settings_file
)
configure_with
(
user_settings
)
configure_with
(
user_settings
)
...
...
spec/unit/config_spec.rb
View file @
5aef67a5
...
@@ -4,7 +4,7 @@ module Pod
...
@@ -4,7 +4,7 @@ module Pod
describe
Config
do
describe
Config
do
before
do
before
do
Config
.
instance
=
nil
@sut
=
Config
.
new
(
false
)
end
end
#-------------------------------------------------------------------------#
#-------------------------------------------------------------------------#
...
@@ -12,27 +12,27 @@ module Pod
...
@@ -12,27 +12,27 @@ module Pod
describe
"In general"
do
describe
"In general"
do
it
"returns the singleton config instance"
do
it
"returns the singleton config instance"
do
config
.
should
.
be
.
instance_of
Config
@sut
.
should
.
be
.
instance_of
Config
end
end
it
"returns the path to the spec-repos dir"
do
it
"returns the path to the spec-repos dir"
do
config
.
repos_dir
.
should
==
Pathname
.
new
(
"~/.cocoapods"
).
expand_path
@sut
.
repos_dir
.
should
==
Pathname
.
new
(
"~/.cocoapods"
).
expand_path
end
end
it
"returns the path to the spec-repos dir"
do
it
"returns the path to the spec-repos dir"
do
config
.
repos_dir
.
should
==
Pathname
.
new
(
"~/.cocoapods"
).
expand_path
@sut
.
repos_dir
.
should
==
Pathname
.
new
(
"~/.cocoapods"
).
expand_path
end
end
it
"allows to specify whether the aggressive cache should be used with an environment variable"
do
it
"allows to specify whether the aggressive cache should be used with an environment variable"
do
config
.
aggressive_cache
=
false
@sut
.
aggressive_cache
=
false
ENV
[
'CP_AGGRESSIVE_CACHE'
]
=
'TRUE'
ENV
[
'CP_AGGRESSIVE_CACHE'
]
=
'TRUE'
config
.
aggressive_cache?
.
should
.
be
.
true
@sut
.
aggressive_cache?
.
should
.
be
.
true
ENV
.
delete
(
'CP_AGGRESSIVE_CACHE'
)
ENV
.
delete
(
'CP_AGGRESSIVE_CACHE'
)
end
end
it
"allows to specify the repos dir with an environment variable"
do
it
"allows to specify the repos dir with an environment variable"
do
ENV
[
'CP_REPOS_DIR'
]
=
'~/custom_repos_dir'
ENV
[
'CP_REPOS_DIR'
]
=
'~/custom_repos_dir'
config
.
repos_dir
.
should
==
Pathname
.
new
(
"~/custom_repos_dir"
).
expand_path
@sut
.
repos_dir
.
should
==
Pathname
.
new
(
"~/custom_repos_dir"
).
expand_path
ENV
.
delete
(
'CP_REPOS_DIR'
)
ENV
.
delete
(
'CP_REPOS_DIR'
)
end
end
end
end
...
@@ -44,7 +44,7 @@ module Pod
...
@@ -44,7 +44,7 @@ module Pod
it
"returns the working directory as the installation root if a Podfile can be found"
do
it
"returns the working directory as the installation root if a Podfile can be found"
do
Dir
.
chdir
(
temporary_directory
)
do
Dir
.
chdir
(
temporary_directory
)
do
File
.
open
(
"Podfile"
,
"w"
)
{}
File
.
open
(
"Podfile"
,
"w"
)
{}
config
.
installation_root
.
should
==
temporary_directory
@sut
.
installation_root
.
should
==
temporary_directory
end
end
end
end
...
@@ -54,54 +54,54 @@ module Pod
...
@@ -54,54 +54,54 @@ module Pod
sub_dir
=
temporary_directory
+
'sub_dir'
sub_dir
=
temporary_directory
+
'sub_dir'
sub_dir
.
mkpath
sub_dir
.
mkpath
Dir
.
chdir
(
sub_dir
)
do
Dir
.
chdir
(
sub_dir
)
do
config
.
installation_root
.
should
==
temporary_directory
@sut
.
installation_root
.
should
==
temporary_directory
end
end
end
end
end
end
it
"it returns the working directory as the installation root if no Podfile can be found"
do
it
"it returns the working directory as the installation root if no Podfile can be found"
do
Dir
.
chdir
(
temporary_directory
)
do
Dir
.
chdir
(
temporary_directory
)
do
config
.
installation_root
.
should
==
temporary_directory
@sut
.
installation_root
.
should
==
temporary_directory
end
end
end
end
before
do
before
do
config
.
installation_root
=
temporary_directory
@sut
.
installation_root
=
temporary_directory
end
end
it
"returns the path to the project root"
do
it
"returns the path to the project root"
do
config
.
installation_root
.
should
==
temporary_directory
@sut
.
installation_root
.
should
==
temporary_directory
end
end
it
"returns the path to the project Podfile if it exists"
do
it
"returns the path to the project Podfile if it exists"
do
(
temporary_directory
+
'Podfile'
).
open
(
'w'
)
{
|
f
|
f
<<
'# Yo'
}
(
temporary_directory
+
'Podfile'
).
open
(
'w'
)
{
|
f
|
f
<<
'# Yo'
}
config
.
podfile_path
.
should
==
temporary_directory
+
'Podfile'
@sut
.
podfile_path
.
should
==
temporary_directory
+
'Podfile'
end
end
it
"can detect yaml Podfiles"
do
it
"can detect yaml Podfiles"
do
(
temporary_directory
+
'CocoaPods.podfile.yaml'
).
open
(
'w'
)
{
|
f
|
f
<<
'# Yo'
}
(
temporary_directory
+
'CocoaPods.podfile.yaml'
).
open
(
'w'
)
{
|
f
|
f
<<
'# Yo'
}
config
.
podfile_path
.
should
==
temporary_directory
+
'CocoaPods.podfile.yaml'
@sut
.
podfile_path
.
should
==
temporary_directory
+
'CocoaPods.podfile.yaml'
end
end
it
"can detect files named `CocoaPods.podfile`"
do
it
"can detect files named `CocoaPods.podfile`"
do
(
temporary_directory
+
'CocoaPods.podfile'
).
open
(
'w'
)
{
|
f
|
f
<<
'# Yo'
}
(
temporary_directory
+
'CocoaPods.podfile'
).
open
(
'w'
)
{
|
f
|
f
<<
'# Yo'
}
config
.
podfile_path
.
should
==
temporary_directory
+
'CocoaPods.podfile'
@sut
.
podfile_path
.
should
==
temporary_directory
+
'CocoaPods.podfile'
end
end
it
"returns the path to the Pods directory that holds the dependencies"
do
it
"returns the path to the Pods directory that holds the dependencies"
do
config
.
sandbox_root
.
should
==
temporary_directory
+
'Pods'
@sut
.
sandbox_root
.
should
==
temporary_directory
+
'Pods'
end
end
it
"returns the Podfile path"
do
it
"returns the Podfile path"
do
Dir
.
chdir
(
temporary_directory
)
do
Dir
.
chdir
(
temporary_directory
)
do
File
.
open
(
"Podfile"
,
"w"
)
{}
File
.
open
(
"Podfile"
,
"w"
)
{}
config
.
podfile_path
.
should
==
temporary_directory
+
"Podfile"
@sut
.
podfile_path
.
should
==
temporary_directory
+
"Podfile"
end
end
end
end
it
"returns nils if the Podfile if no paths exists"
do
it
"returns nils if the Podfile if no paths exists"
do
Dir
.
chdir
(
temporary_directory
)
do
Dir
.
chdir
(
temporary_directory
)
do
config
.
podfile_path
.
should
==
nil
@sut
.
podfile_path
.
should
==
nil
end
end
end
end
...
@@ -109,16 +109,16 @@ module Pod
...
@@ -109,16 +109,16 @@ module Pod
Dir
.
chdir
(
temporary_directory
)
do
Dir
.
chdir
(
temporary_directory
)
do
File
.
open
(
"Podfile"
,
"w"
)
{}
File
.
open
(
"Podfile"
,
"w"
)
{}
File
.
open
(
"Podfile.lock"
,
"w"
)
{}
File
.
open
(
"Podfile.lock"
,
"w"
)
{}
config
.
lockfile_path
.
should
==
temporary_directory
+
"Podfile.lock"
@sut
.
lockfile_path
.
should
==
temporary_directory
+
"Podfile.lock"
end
end
end
end
it
"returns the statistics cache file"
do
it
"returns the statistics cache file"
do
config
.
statistics_cache_file
.
to_s
.
should
.
end_with?
(
'statistics.yml'
)
@sut
.
statistics_cache_file
.
to_s
.
should
.
end_with?
(
'statistics.yml'
)
end
end
it
"returns the search index file"
do
it
"returns the search index file"
do
config
.
search_index_file
.
to_s
.
should
.
end_with?
(
'search_index.yaml'
)
@sut
.
search_index_file
.
to_s
.
should
.
end_with?
(
'search_index.yaml'
)
end
end
end
end
...
@@ -127,32 +127,28 @@ module Pod
...
@@ -127,32 +127,28 @@ module Pod
describe
"Default settings"
do
describe
"Default settings"
do
before
do
Config
.
any_instance
.
stubs
(
:user_settings_file
).
returns
(
Pathname
.
new
(
'not_found'
))
end
it
"prints out normal information"
do
it
"prints out normal information"
do
config
.
should
.
not
.
be
.
silent
@sut
.
should
.
not
.
be
.
silent
end
end
it
"does not print verbose information"
do
it
"does not print verbose information"
do
config
.
should
.
not
.
be
.
verbose
@sut
.
should
.
not
.
be
.
verbose
end
end
it
"cleans SCM dirs in dependency checkouts"
do
it
"cleans SCM dirs in dependency checkouts"
do
config
.
should
.
clean
@sut
.
should
.
clean
end
end
it
"has a default cache size of 500"
do
it
"has a default cache size of 500"
do
config
.
max_cache_size
.
should
==
500
@sut
.
max_cache_size
.
should
==
500
end
end
it
"returns the cache root"
do
it
"returns the cache root"
do
config
.
cache_root
.
should
==
Pathname
.
new
(
File
.
join
(
ENV
[
'HOME'
],
'Library/Caches/CocoaPods'
))
@sut
.
cache_root
.
should
==
Pathname
.
new
(
File
.
join
(
ENV
[
'HOME'
],
'Library/Caches/CocoaPods'
))
end
end
it
"doesn't use aggressive cache"
do
it
"doesn't use aggressive cache"
do
config
.
should
.
not
.
aggressive_cache?
@sut
.
should
.
not
.
aggressive_cache?
end
end
end
end
...
@@ -162,17 +158,17 @@ module Pod
...
@@ -162,17 +158,17 @@ module Pod
describe
"Dependency Injection"
do
describe
"Dependency Injection"
do
it
"returns the downloader"
do
it
"returns the downloader"
do
downloader
=
config
.
downloader
(
Pathname
.
new
(
''
),
{
:git
=>
'example.com'
})
downloader
=
@sut
.
downloader
(
Pathname
.
new
(
''
),
{
:git
=>
'example.com'
})
downloader
.
target_path
.
should
==
Pathname
.
new
(
''
)
downloader
.
target_path
.
should
==
Pathname
.
new
(
''
)
downloader
.
url
.
should
==
'example.com'
downloader
.
url
.
should
==
'example.com'
downloader
.
cache_root
.
should
==
config
.
cache_root
downloader
.
cache_root
.
should
==
@sut
.
cache_root
downloader
.
max_cache_size
.
should
==
500
downloader
.
max_cache_size
.
should
==
500
downloader
.
aggressive_cache
.
should
.
be
.
false
downloader
.
aggressive_cache
.
should
.
be
.
false
end
end
it
"returns the specification statistics provider"
do
it
"returns the specification statistics provider"
do
stats_provider
=
config
.
spec_statistics_provider
stats_provider
=
@sut
.
spec_statistics_provider
stats_provider
.
cache_file
.
should
==
config
.
cache_root
+
'statistics.yml'
stats_provider
.
cache_file
.
should
==
@sut
.
cache_root
+
'statistics.yml'
end
end
end
end
...
@@ -182,13 +178,13 @@ module Pod
...
@@ -182,13 +178,13 @@ module Pod
describe
"Private helpers"
do
describe
"Private helpers"
do
it
"returns the path of the user settings file"
do
it
"returns the path of the user settings file"
do
config
.
send
(
:user_settings_file
).
should
==
Pathname
.
new
(
"~/.cocoapods/config.yaml"
).
expand_path
@sut
.
send
(
:user_settings_file
).
should
==
Pathname
.
new
(
"~/.cocoapods/config.yaml"
).
expand_path
end
end
it
"can be configured with a hash"
do
it
"can be configured with a hash"
do
hash
=
{
:verbose
=>
true
}
hash
=
{
:verbose
=>
true
}
config
.
send
(
:configure_with
,
hash
)
@sut
.
send
(
:configure_with
,
hash
)
config
.
should
.
be
.
verbose
@sut
.
should
.
be
.
verbose
end
end
#----------------------------------------#
#----------------------------------------#
...
@@ -198,26 +194,26 @@ module Pod
...
@@ -198,26 +194,26 @@ module Pod
it
"detects the CocoaPods.podfile.yaml file"
do
it
"detects the CocoaPods.podfile.yaml file"
do
expected
=
temporary_directory
+
"CocoaPods.podfile.yaml"
expected
=
temporary_directory
+
"CocoaPods.podfile.yaml"
File
.
open
(
expected
,
"w"
)
{}
File
.
open
(
expected
,
"w"
)
{}
path
=
config
.
send
(
:podfile_path_in_dir
,
temporary_directory
)
path
=
@sut
.
send
(
:podfile_path_in_dir
,
temporary_directory
)
path
.
should
==
expected
path
.
should
==
expected
end
end
it
"detects the CocoaPods.podfile file"
do
it
"detects the CocoaPods.podfile file"
do
expected
=
temporary_directory
+
"CocoaPods.podfile"
expected
=
temporary_directory
+
"CocoaPods.podfile"
File
.
open
(
expected
,
"w"
)
{}
File
.
open
(
expected
,
"w"
)
{}
path
=
config
.
send
(
:podfile_path_in_dir
,
temporary_directory
)
path
=
@sut
.
send
(
:podfile_path_in_dir
,
temporary_directory
)
path
.
should
==
expected
path
.
should
==
expected
end
end
it
"detects the Podfile file"
do
it
"detects the Podfile file"
do
expected
=
temporary_directory
+
"Podfile"
expected
=
temporary_directory
+
"Podfile"
File
.
open
(
expected
,
"w"
)
{}
File
.
open
(
expected
,
"w"
)
{}
path
=
config
.
send
(
:podfile_path_in_dir
,
temporary_directory
)
path
=
@sut
.
send
(
:podfile_path_in_dir
,
temporary_directory
)
path
.
should
==
expected
path
.
should
==
expected
end
end
it
"returns nils if the Podfile is not available"
do
it
"returns nils if the Podfile is not available"
do
path
=
config
.
send
(
:podfile_path_in_dir
,
temporary_directory
)
path
=
@sut
.
send
(
:podfile_path_in_dir
,
temporary_directory
)
path
.
should
==
nil
path
.
should
==
nil
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