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
ae244a6f
Commit
ae244a6f
authored
Apr 12, 2014
by
Boris Bügling
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feature-allow-homepage-redirects
Conflicts: lib/cocoapods/validator.rb
parents
7691aedd
d3b515b3
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
201 additions
and
51 deletions
+201
-51
CHANGELOG.md
CHANGELOG.md
+18
-0
Gemfile.lock
Gemfile.lock
+5
-5
cocoapods.rb
lib/cocoapods.rb
+0
-21
command.rb
lib/cocoapods/command.rb
+3
-0
spec.rb
lib/cocoapods/command/spec.rb
+1
-1
external_sources.rb
lib/cocoapods/external_sources.rb
+8
-2
prefix_header.rb
lib/cocoapods/generator/prefix_header.rb
+14
-5
installer.rb
lib/cocoapods/installer.rb
+3
-2
sandbox.rb
lib/cocoapods/sandbox.rb
+17
-2
validator.rb
lib/cocoapods/validator.rb
+29
-9
cocoapods-integration-specs
spec/cocoapods-integration-specs
+1
-1
command_spec.rb
spec/functional/command_spec.rb
+4
-0
integration.rb
spec/integration.rb
+4
-0
prefix_header_spec.rb
spec/unit/generator/prefix_header_spec.rb
+37
-0
installer_spec.rb
spec/unit/installer_spec.rb
+19
-0
validator_spec.rb
spec/unit/validator_spec.rb
+38
-3
No files found.
CHANGELOG.md
View file @
ae244a6f
...
@@ -20,6 +20,19 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
...
@@ -20,6 +20,19 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[
Piet Brauer
](
https://github.com/pietbrauer
)
[
Piet Brauer
](
https://github.com/pietbrauer
)
[
Orta Therox
](
https://github.com/orta
)
[
Orta Therox
](
https://github.com/orta
)
*
Validate the reachability of screenshot URLs in podspecs while linting a
specification.
[
Kyle Fuller
](
https://github.com/kylef
)
[
#2010
](
https://github.com/CocoaPods/CocoaPods/issues/2010
)
*
Prevent the user from using
`pod`
commands as root
[
Kyle Fuller
](
https://github.com/kylef
)
[
#1815
](
https://github.com/CocoaPods/CocoaPods/issues/1815
)
*
Fix to keep absolute paths specified for local pods as is.
[
Samuel Ford
](
https://github.com/samuelwford
)
[
#1042
](
https://github.com/CocoaPods/CocoaPods/issues/1042
)
## 0.31.1
## 0.31.1
[
CocoaPods
](
https://github.com/CocoaPods/CocoaPods/compare/0.31.1...0.31.0
)
[
CocoaPods
](
https://github.com/CocoaPods/CocoaPods/compare/0.31.1...0.31.0
)
•
[
CocoaPods-Core
](
https://github.com/CocoaPods/Core/compare/0.31.1...0.31.0
)
•
[
CocoaPods-Core
](
https://github.com/CocoaPods/Core/compare/0.31.1...0.31.0
)
...
@@ -55,6 +68,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
...
@@ -55,6 +68,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[
Robert Zuber
](
https://github.com/z00b
)
[
Robert Zuber
](
https://github.com/z00b
)
[
#1617
](
https://github.com/CocoaPods/CocoaPods/issues/1617
)
[
#1617
](
https://github.com/CocoaPods/CocoaPods/issues/1617
)
*
Generated prefix header file will now have unique prefix_header_contents for
Pods with subspecs.
[
Luis de la Rosa
](
https://github.com/luisdelarosa
)
[
#1449
](
https://github.com/CocoaPods/CocoaPods/issues/1449
)
*
The linter will now check the reachability of the homepage of Podspecs during
*
The linter will now check the reachability of the homepage of Podspecs during
a full lint.
a full lint.
[
Richard Lee
](
https://github.com/dlackty
)
[
Richard Lee
](
https://github.com/dlackty
)
...
...
Gemfile.lock
View file @
ae244a6f
...
@@ -7,7 +7,7 @@ GIT
...
@@ -7,7 +7,7 @@ GIT
GIT
GIT
remote: https://github.com/CocoaPods/Core.git
remote: https://github.com/CocoaPods/Core.git
revision:
5736f3cfbebe805c04e67a53729b9fa098ea8f9d
revision:
a6d129d9a72bd7324414001daacbe8bfd96b2311
branch: master
branch: master
specs:
specs:
cocoapods-core (0.31.1)
cocoapods-core (0.31.1)
...
@@ -59,10 +59,10 @@ GIT
...
@@ -59,10 +59,10 @@ GIT
GIT
GIT
remote: https://github.com/irrationalfab/PrettyBacon.git
remote: https://github.com/irrationalfab/PrettyBacon.git
revision:
eaf7e6c786fd5ccc6fb88e943bf7c5e6c27569a3
revision:
1eeb06f7d381acd65414b86b42fdf3538faae01c
branch: master
branch: master
specs:
specs:
prettybacon (0.0.
1
)
prettybacon (0.0.
2
)
bacon (~> 1.2)
bacon (~> 1.2)
GIT
GIT
...
@@ -148,7 +148,7 @@ GEM
...
@@ -148,7 +148,7 @@ GEM
redcarpet (2.3.0)
redcarpet (2.3.0)
rest-client (1.6.7)
rest-client (1.6.7)
mime-types (>= 1.16)
mime-types (>= 1.16)
safe_yaml (1.0.
1
)
safe_yaml (1.0.
2
)
simplecov (0.8.2)
simplecov (0.8.2)
docile (~> 1.1.0)
docile (~> 1.1.0)
multi_json
multi_json
...
@@ -158,7 +158,7 @@ GEM
...
@@ -158,7 +158,7 @@ GEM
term-ansicolor (1.3.0)
term-ansicolor (1.3.0)
tins (~> 1.0)
tins (~> 1.0)
thor (0.19.1)
thor (0.19.1)
tins (1.
0.1
)
tins (1.
1.0
)
webmock (1.15.2)
webmock (1.15.2)
addressable (>= 2.2.7)
addressable (>= 2.2.7)
crack (>= 0.3.2)
crack (>= 0.3.2)
...
...
lib/cocoapods.rb
View file @
ae244a6f
...
@@ -72,24 +72,3 @@ if ENV['COCOA_PODS_ENV'] == 'development'
...
@@ -72,24 +72,3 @@ if ENV['COCOA_PODS_ENV'] == 'development'
# require 'awesome_print'
# require 'awesome_print'
# require 'pry'
# require 'pry'
end
end
# TODO remove for CocoaPods 0.31
#
module
Pod
class
Specification
def
pre_install
(
&
block
)
UI
.
warn
"[
#{
self
}
] The pre install hook of the specification "
\
"DSL has been deprecated, use the `resource_bundles` or the "
\
"`prepare_command` attributes."
UI
.
puts
"[
#{
self
}
] The pre_install hook will be removed in the next release"
.
red
@pre_install_callback
=
block
end
def
post_install
(
&
block
)
UI
.
warn
"[
#{
self
}
] The post install hook of the specification "
\
"DSL has been deprecated, use the `resource_bundles` or the "
\
"`prepare_command` attributes."
UI
.
puts
"[
#{
self
}
] The post_install hook will be removed in the next release"
.
red
@post_install_callback
=
block
end
end
end
lib/cocoapods/command.rb
View file @
ae244a6f
...
@@ -43,11 +43,14 @@ module Pod
...
@@ -43,11 +43,14 @@ module Pod
end
end
def
self
.
run
(
argv
)
def
self
.
run
(
argv
)
help!
"You cannot run CocoaPods as root."
if
Process
.
uid
==
0
argv
=
CLAide
::
ARGV
.
new
(
argv
)
argv
=
CLAide
::
ARGV
.
new
(
argv
)
if
argv
.
flag?
(
'version'
)
if
argv
.
flag?
(
'version'
)
UI
.
puts
VERSION
UI
.
puts
VERSION
exit
0
exit
0
end
end
super
(
argv
)
super
(
argv
)
UI
.
print_warnings
UI
.
print_warnings
end
end
...
...
lib/cocoapods/command/spec.rb
View file @
ae244a6f
...
@@ -480,7 +480,7 @@ Pod::Spec.new do |s|
...
@@ -480,7 +480,7 @@ Pod::Spec.new do |s|
DESC
DESC
s.homepage = "
#{
data
[
:homepage
]
}
"
s.homepage = "
#{
data
[
:homepage
]
}
"
# s.screenshots = "www.example.com/screenshots_1
", "www.example.com/screenshots_2
"
# s.screenshots = "www.example.com/screenshots_1
.gif", "www.example.com/screenshots_2.gif
"
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
...
...
lib/cocoapods/external_sources.rb
View file @
ae244a6f
...
@@ -352,7 +352,8 @@ module Pod
...
@@ -352,7 +352,8 @@ module Pod
UI
.
titled_section
(
"Fetching podspec for `
#{
name
}
`
#{
description
}
"
,
{
:verbose_prefix
=>
"-> "
})
do
UI
.
titled_section
(
"Fetching podspec for `
#{
name
}
`
#{
description
}
"
,
{
:verbose_prefix
=>
"-> "
})
do
podspec
=
podspec_path
podspec
=
podspec_path
store_podspec
(
sandbox
,
podspec
)
store_podspec
(
sandbox
,
podspec
)
sandbox
.
store_local_path
(
name
,
podspec
.
dirname
)
path_is_absolute_or_rooted_to_home
=
declared_path
.
absolute?
||
declared_path
.
to_s
.
start_with?
(
'~'
)
sandbox
.
store_local_path
(
name
,
podspec
.
dirname
,
path_is_absolute_or_rooted_to_home
)
end
end
end
end
...
@@ -368,10 +369,15 @@ module Pod
...
@@ -368,10 +369,15 @@ module Pod
# @!group Helpers
# @!group Helpers
# @return [Pathname] the path as declared in the podspec
#
def
declared_path
Pathname
.
new
params
[
:path
]
||
params
[
:local
]
end
# @return [Pathname] the path of the podspec.
# @return [Pathname] the path of the podspec.
#
#
def
podspec_path
def
podspec_path
declared_path
=
(
params
[
:path
]
||
params
[
:local
]).
to_s
path_with_ext
=
File
.
extname
(
declared_path
)
==
'.podspec'
?
declared_path
:
"
#{
declared_path
}
/
#{
name
}
.podspec"
path_with_ext
=
File
.
extname
(
declared_path
)
==
'.podspec'
?
declared_path
:
"
#{
declared_path
}
/
#{
name
}
.podspec"
podfile_dir
=
File
.
dirname
(
podfile_path
||
''
)
podfile_dir
=
File
.
dirname
(
podfile_path
||
''
)
absolute_path
=
File
.
expand_path
(
path_with_ext
,
podfile_dir
)
absolute_path
=
File
.
expand_path
(
path_with_ext
,
podfile_dir
)
...
...
lib/cocoapods/generator/prefix_header.rb
View file @
ae244a6f
...
@@ -40,9 +40,12 @@ module Pod
...
@@ -40,9 +40,12 @@ module Pod
# added to the top of the prefix header. For OS X `Cocoa/Cocoa.h`
# added to the top of the prefix header. For OS X `Cocoa/Cocoa.h`
# is imported.
# is imported.
#
#
# @note Only unique prefix_header_contents are added to the prefix header.
#
# @return [String]
# @return [String]
#
#
# @todo Subspecs can specify prefix header information too.
# @todo Subspecs can specify prefix header information too.
# @todo Check to see if we have a similar duplication issue with file_accessor.prefix_header.
#
#
def
generate
def
generate
result
=
"#ifdef __OBJC__
\n
"
result
=
"#ifdef __OBJC__
\n
"
...
@@ -53,12 +56,18 @@ module Pod
...
@@ -53,12 +56,18 @@ module Pod
result
<<
%|\n#import "#{import}"|
result
<<
%|\n#import "#{import}"|
end
end
file_accessors
.
each
do
|
file_accessor
|
unique_prefix_header_contents
=
file_accessors
.
collect
do
|
file_accessor
|
file_accessor
.
spec_consumer
.
prefix_header_contents
end
.
compact
.
uniq
result
<<
"
\n
"
unique_prefix_header_contents
.
each
do
|
prefix_header_contents
|
result
<<
prefix_header_contents
result
<<
"
\n
"
result
<<
"
\n
"
if
prefix_header_contents
=
file_accessor
.
spec_consumer
.
prefix_header_contents
end
result
<<
prefix_header_contents
result
<<
"
\n
"
file_accessors
.
each
do
|
file_accessor
|
end
if
prefix_header
=
file_accessor
.
prefix_header
if
prefix_header
=
file_accessor
.
prefix_header
result
<<
Pathname
(
prefix_header
).
read
result
<<
Pathname
(
prefix_header
).
read
end
end
...
...
lib/cocoapods/installer.rb
View file @
ae244a6f
...
@@ -296,9 +296,10 @@ module Pod
...
@@ -296,9 +296,10 @@ module Pod
pod_names
=
pod_targets
.
map
(
&
:pod_name
).
uniq
pod_names
=
pod_targets
.
map
(
&
:pod_name
).
uniq
pod_names
.
each
do
|
pod_name
|
pod_names
.
each
do
|
pod_name
|
path
=
sandbox
.
pod_dir
(
pod_name
)
local
=
sandbox
.
local?
(
pod_name
)
local
=
sandbox
.
local?
(
pod_name
)
@pods_project
.
add_pod_group
(
pod_name
,
path
,
local
)
path
=
sandbox
.
pod_dir
(
pod_name
)
was_absolute
=
sandbox
.
local_path_was_absolute?
(
pod_name
)
@pods_project
.
add_pod_group
(
pod_name
,
path
,
local
,
was_absolute
)
end
end
if
config
.
podfile_path
if
config
.
podfile_path
...
...
lib/cocoapods/sandbox.rb
View file @
ae244a6f
...
@@ -69,6 +69,7 @@ module Pod
...
@@ -69,6 +69,7 @@ module Pod
@head_pods
=
[]
@head_pods
=
[]
@checkout_sources
=
{}
@checkout_sources
=
{}
@development_pods
=
{}
@development_pods
=
{}
@pods_with_absolute_path
=
[]
end
end
# @return [Lockfile] the manifest which contains the information about the
# @return [Lockfile] the manifest which contains the information about the
...
@@ -158,7 +159,17 @@ module Pod
...
@@ -158,7 +159,17 @@ module Pod
root
+
root_name
root
+
root_name
end
end
end
end
# Returns true if the path as originally specified was absolute.
#
# @param [String] name
#
# @return [Bool] true if originally absolute
#
def
local_path_was_absolute?
(
name
)
@pods_with_absolute_path
.
include?
name
end
# @return [Pathname] the directory where to store the documentation.
# @return [Pathname] the directory where to store the documentation.
#
#
def
documentation_dir
def
documentation_dir
...
@@ -338,11 +349,15 @@ module Pod
...
@@ -338,11 +349,15 @@ module Pod
# @param [#to_s] path
# @param [#to_s] path
# The local path where the Pod is stored.
# The local path where the Pod is stored.
#
#
# @param [Bool] was_absolute
# True if the specified local path was absolute.
#
# @return [void]
# @return [void]
#
#
def
store_local_path
(
name
,
path
)
def
store_local_path
(
name
,
path
,
was_absolute
=
false
)
root_name
=
Specification
.
root_name
(
name
)
root_name
=
Specification
.
root_name
(
name
)
development_pods
[
root_name
]
=
path
.
to_s
development_pods
[
root_name
]
=
path
.
to_s
@pods_with_absolute_path
<<
root_name
if
was_absolute
end
end
# @return [Hash{String=>String}] The path of the Pods with a local source
# @return [Hash{String=>String}] The path of the Pods with a local source
...
...
lib/cocoapods/validator.rb
View file @
ae244a6f
...
@@ -197,6 +197,7 @@ module Pod
...
@@ -197,6 +197,7 @@ module Pod
#
#
def
perform_extensive_analysis
(
spec
)
def
perform_extensive_analysis
(
spec
)
validate_homepage
(
spec
)
validate_homepage
(
spec
)
validate_screenshots
(
spec
)
spec
.
available_platforms
.
each
do
|
platform
|
spec
.
available_platforms
.
each
do
|
platform
|
UI
.
message
"
\n\n
#{
spec
}
- Analyzing on
#{
platform
}
platform."
.
green
.
reversed
UI
.
message
"
\n\n
#{
spec
}
- Analyzing on
#{
platform
}
platform."
.
green
.
reversed
...
@@ -224,25 +225,23 @@ module Pod
...
@@ -224,25 +225,23 @@ module Pod
MAX_HTTP_REDIRECTS
=
3
MAX_HTTP_REDIRECTS
=
3
# Performs validation
s related to the `homepage` attribute.
# Performs validation
of a URL
#
#
def
validate_
homepage
(
spec
)
def
validate_
url
(
url
)
require
'rest'
require
'rest'
homepage
=
spec
.
homepage
return
unless
homepage
begin
begin
redirects
=
0
redirects
=
0
resp
=
nil
resp
=
nil
loop
do
loop
do
resp
=
::
REST
.
head
(
homepage
)
resp
=
::
REST
.
head
(
url
)
if
resp
.
status_code
==
405
if
resp
.
status_code
==
405
resp
=
::
REST
.
get
(
homepage
)
resp
=
::
REST
.
get
(
url
)
end
end
if
[
301
,
302
,
303
,
307
,
308
].
include?
resp
.
status_code
if
[
301
,
302
,
303
,
307
,
308
].
include?
resp
.
status_code
homepage
=
resp
.
headers
[
'location'
].
first
url
=
resp
.
headers
[
'location'
].
first
redirects
+=
1
redirects
+=
1
else
else
break
break
...
@@ -251,12 +250,33 @@ module Pod
...
@@ -251,12 +250,33 @@ module Pod
break
unless
redirects
<
MAX_HTTP_REDIRECTS
break
unless
redirects
<
MAX_HTTP_REDIRECTS
end
end
rescue
rescue
warning
"There was a problem validating the
homepage
."
warning
"There was a problem validating the
URL
#{
url
}
."
resp
=
nil
resp
=
nil
end
end
if
resp
&&
!
resp
.
success?
if
resp
&&
!
resp
.
success?
warning
"The homepage is not reachable."
warning
"The URL (
#{
url
}
) is not reachable."
end
resp
end
# Performs validations related to the `homepage` attribute.
#
def
validate_homepage
(
spec
)
if
spec
.
homepage
validate_url
(
spec
.
homepage
)
end
end
# Performs validation related to the `screenshots` attribute.
#
def
validate_screenshots
(
spec
)
spec
.
screenshots
.
each
do
|
screenshot
|
request
=
validate_url
(
screenshot
)
if
request
&&
!
(
request
.
headers
[
'content-type'
]
&&
request
.
headers
[
'content-type'
].
first
=~
/image\/.*/i
)
warning
"The screenshot
#{
screenshot
}
is not a valid image."
end
end
end
end
end
...
...
cocoapods-integration-specs
@
eced44cc
Subproject commit
d0378da111a5368a28c019e57e4a9f3d3d8e9d94
Subproject commit
eced44cc9e4bf19ce9c3b6d68dc4806af25252fa
spec/functional/command_spec.rb
View file @
ae244a6f
...
@@ -14,5 +14,9 @@ module Pod
...
@@ -14,5 +14,9 @@ module Pod
UI
.
output
.
should
.
include
'spec/fixtures/spec-repos/master/AFNetworking'
UI
.
output
.
should
.
include
'spec/fixtures/spec-repos/master/AFNetworking'
end
end
it
"doesn't let you run as root"
do
Process
.
stubs
(
:uid
).
returns
(
0
)
lambda
{
Pod
::
Command
.
run
([
'--version'
])
}.
should
.
raise
CLAide
::
Help
end
end
end
end
end
spec/integration.rb
View file @
ae244a6f
...
@@ -331,6 +331,10 @@ describe "Integration" do
...
@@ -331,6 +331,10 @@ describe "Integration" do
check
"install --no-repo-update"
,
"install_subspecs"
check
"install --no-repo-update"
,
"install_subspecs"
end
end
describe
"Installs a Pod with subspecs and does not duplicate the prefix header"
do
check
"install --no-repo-update"
,
"install_subspecs_no_duplicate_prefix"
end
describe
"Installs a Pod with a local source"
do
describe
"Installs a Pod with a local source"
do
check
"install --no-repo-update"
,
"install_local_source"
check
"install --no-repo-update"
,
"install_local_source"
end
end
...
...
spec/unit/generator/prefix_header_spec.rb
View file @
ae244a6f
...
@@ -21,6 +21,43 @@ module Pod
...
@@ -21,6 +21,43 @@ module Pod
EOS
EOS
end
end
# @note Declaring a subspec was found in issue #1449 to generate duplicates of the prefix_header_contents
it
"does not duplicate the contents of the specification's prefix header when a subspec is declared"
do
@spec
.
prefix_header_contents
=
'#import "BlocksKit.h"'
@spec
.
prefix_header_file
=
nil
@spec
.
subspec
'UI'
do
|
subspec
|
subspec
.
source_files
=
'Source/UI/*.{h,m}'
end
@gen
.
generate
.
should
==
<<-
EOS
.
strip_heredoc
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "BlocksKit.h"
EOS
end
# @note Declaring a subspec was found in issue #1449 to generate duplicates of the prefix_header_contents
it
"does not duplicate the contents of the specification's prefix header when a subspec is declared multiple times"
do
@spec
.
prefix_header_contents
=
'#import "BlocksKit.h"'
@spec
.
prefix_header_file
=
nil
@spec
.
subspec
'UI'
do
|
su
|
su
.
source_files
=
'Source/UI/*.{h,m}'
end
@spec
.
subspec
'Helpers'
do
|
sh
|
sh
.
source_files
=
'Source/Helpers/*.{h,m}'
end
@gen
.
generate
.
should
==
<<-
EOS
.
strip_heredoc
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
#import "BlocksKit.h"
EOS
end
it
"includes the contents of the specification's prefix header file"
do
it
"includes the contents of the specification's prefix header file"
do
@gen
.
generate
.
should
==
<<-
EOS
.
strip_heredoc
@gen
.
generate
.
should
==
<<-
EOS
.
strip_heredoc
#ifdef __OBJC__
#ifdef __OBJC__
...
...
spec/unit/installer_spec.rb
View file @
ae244a6f
...
@@ -21,6 +21,16 @@ def generate_podfile(pods = ['JSONKit'])
...
@@ -21,6 +21,16 @@ def generate_podfile(pods = ['JSONKit'])
end
end
end
end
# @return [Podfile]
#
def
generate_local_podfile
podfile
=
Pod
::
Podfile
.
new
do
platform
:ios
xcodeproj
SpecHelper
.
fixture
(
'SampleProject/SampleProject'
),
'Test'
=>
:debug
,
'App Store'
=>
:release
pod
'SSToolkit'
,
:path
=>
SpecHelper
.
fixture
(
'integration/sstoolkit'
)
end
end
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
module
Pod
module
Pod
...
@@ -247,6 +257,15 @@ module Pod
...
@@ -247,6 +257,15 @@ module Pod
@installer
.
pods_project
.
class
.
should
==
Pod
::
Project
@installer
.
pods_project
.
class
.
should
==
Pod
::
Project
end
end
it
"preserves Pod paths specified as absolute or rooted to home"
do
local_podfile
=
generate_local_podfile
local_installer
=
Installer
.
new
(
config
.
sandbox
,
local_podfile
)
local_installer
.
send
(
:analyze
)
local_installer
.
send
(
:prepare_pods_project
)
group
=
local_installer
.
pods_project
.
group_for_spec
(
'SSToolkit'
)
Pathname
.
new
(
group
.
path
).
should
.
be
.
absolute
end
it
"adds the Podfile to the Pods project"
do
it
"adds the Podfile to the Pods project"
do
config
.
stubs
(
:podfile_path
).
returns
(
Pathname
.
new
(
'/Podfile'
))
config
.
stubs
(
:podfile_path
).
returns
(
Pathname
.
new
(
'/Podfile'
))
@installer
.
send
(
:prepare_pods_project
)
@installer
.
send
(
:prepare_pods_project
)
...
...
spec/unit/validator_spec.rb
View file @
ae244a6f
...
@@ -75,6 +75,7 @@ module Pod
...
@@ -75,6 +75,7 @@ module Pod
validator
=
Validator
.
new
(
file
)
validator
=
Validator
.
new
(
file
)
validator
.
quick
=
true
validator
.
quick
=
true
validator
.
stubs
(
:validate_homepage
)
validator
.
stubs
(
:validate_homepage
)
validator
.
stubs
(
:validate_screenshots
)
validator
.
validate
validator
.
validate
validator
.
validation_dir
.
should
.
be
==
Pathname
.
new
(
"/private/tmp/CocoaPods/Lint"
)
validator
.
validation_dir
.
should
.
be
==
Pathname
.
new
(
"/private/tmp/CocoaPods/Lint"
)
end
end
...
@@ -99,14 +100,14 @@ module Pod
...
@@ -99,14 +100,14 @@ module Pod
WebMock
::
API
.
stub_request
(
:head
,
/not-found/
).
to_return
(
:status
=>
404
)
WebMock
::
API
.
stub_request
(
:head
,
/not-found/
).
to_return
(
:status
=>
404
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/not-found/'
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/not-found/'
)
@sut
.
validate
@sut
.
validate
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/The
homepage
is not reachable/
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/The
URL (.*)
is not reachable/
end
end
it
"indicates if it was not able to validate the homepage"
do
it
"indicates if it was not able to validate the homepage"
do
WebMock
::
API
.
stub_request
(
:head
,
'banana-corp.local'
).
to_raise
(
SocketError
)
WebMock
::
API
.
stub_request
(
:head
,
'banana-corp.local'
).
to_raise
(
SocketError
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/'
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/'
)
@sut
.
validate
@sut
.
validate
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/There was a problem validating the
homepage
/
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/There was a problem validating the
URL
/
end
end
it
"does not fail if the homepage redirects"
do
it
"does not fail if the homepage redirects"
do
...
@@ -131,7 +132,34 @@ module Pod
...
@@ -131,7 +132,34 @@ module Pod
:status
=>
301
,
:headers
=>
{
'Location'
=>
'http://banana-corp.local/redirect/'
}
)
:status
=>
301
,
:headers
=>
{
'Location'
=>
'http://banana-corp.local/redirect/'
}
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/redirect/'
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/redirect/'
)
@sut
.
validate
@sut
.
validate
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/The homepage is not reachable/
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/The URL \(.*\) is not reachable/
end
end
describe
"Screenshot validation"
do
require
'webmock'
before
do
@sut
=
Validator
.
new
(
podspec_path
)
@sut
.
stubs
(
:install_pod
)
@sut
.
stubs
(
:build_pod
)
@sut
.
stubs
(
:check_file_patterns
)
@sut
.
stubs
(
:tear_down_validation_environment
)
@sut
.
stubs
(
:validate_homepage
)
WebMock
::
API
.
stub_request
(
:head
,
'banana-corp.local/valid-image.png'
).
to_return
(
:status
=>
200
,
:headers
=>
{
'Content-Type'
=>
'image/png'
})
end
it
"checks if the screenshots are valid"
do
Specification
.
any_instance
.
stubs
(
:screenshots
).
returns
([
'http://banana-corp.local/valid-image.png'
])
@sut
.
validate
@sut
.
results
.
should
.
be
.
empty?
end
it
"should fail if any of the screenshots URLS do not return an image"
do
WebMock
::
API
.
stub_request
(
:head
,
'banana-corp.local/'
).
to_return
(
:status
=>
200
)
Specification
.
any_instance
.
stubs
(
:screenshots
).
returns
([
'http://banana-corp.local/valid-image.png'
,
'http://banana-corp.local/'
])
@sut
.
validate
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/The screenshot .* is not a valid image/
end
end
end
end
...
@@ -139,6 +167,7 @@ module Pod
...
@@ -139,6 +167,7 @@ module Pod
file
=
write_podspec
(
stub_podspec
)
file
=
write_podspec
(
stub_podspec
)
sut
=
Validator
.
new
(
file
)
sut
=
Validator
.
new
(
file
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
sut
.
no_clean
=
true
sut
.
no_clean
=
true
sut
.
validate
sut
.
validate
sut
.
validation_dir
.
should
.
exist
sut
.
validation_dir
.
should
.
exist
...
@@ -148,6 +177,7 @@ module Pod
...
@@ -148,6 +177,7 @@ module Pod
file
=
write_podspec
(
stub_podspec
)
file
=
write_podspec
(
stub_podspec
)
sut
=
Validator
.
new
(
file
)
sut
=
Validator
.
new
(
file
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
sut
.
expects
(
:install_pod
).
twice
sut
.
expects
(
:install_pod
).
twice
sut
.
expects
(
:build_pod
).
twice
sut
.
expects
(
:build_pod
).
twice
sut
.
expects
(
:check_file_patterns
).
twice
sut
.
expects
(
:check_file_patterns
).
twice
...
@@ -157,6 +187,7 @@ module Pod
...
@@ -157,6 +187,7 @@ module Pod
it
"uses the deployment target of the specification"
do
it
"uses the deployment target of the specification"
do
sut
=
Validator
.
new
(
podspec_path
)
sut
=
Validator
.
new
(
podspec_path
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
podfile
=
sut
.
send
(
:podfile_from_spec
,
:ios
,
'5.0'
)
podfile
=
sut
.
send
(
:podfile_from_spec
,
:ios
,
'5.0'
)
dependency
=
podfile
.
target_definitions
[
'Pods'
].
dependencies
.
first
dependency
=
podfile
.
target_definitions
[
'Pods'
].
dependencies
.
first
dependency
.
external_source
.
has_key?
(
:podspec
).
should
.
be
.
true
dependency
.
external_source
.
has_key?
(
:podspec
).
should
.
be
.
true
...
@@ -165,6 +196,7 @@ module Pod
...
@@ -165,6 +196,7 @@ module Pod
it
"respects the local option"
do
it
"respects the local option"
do
sut
=
Validator
.
new
(
podspec_path
)
sut
=
Validator
.
new
(
podspec_path
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
podfile
=
sut
.
send
(
:podfile_from_spec
,
:ios
,
'5.0'
)
podfile
=
sut
.
send
(
:podfile_from_spec
,
:ios
,
'5.0'
)
deployment_target
=
podfile
.
target_definitions
[
'Pods'
].
platform
.
deployment_target
deployment_target
=
podfile
.
target_definitions
[
'Pods'
].
platform
.
deployment_target
deployment_target
.
to_s
.
should
==
"5.0"
deployment_target
.
to_s
.
should
==
"5.0"
...
@@ -175,6 +207,7 @@ module Pod
...
@@ -175,6 +207,7 @@ module Pod
sut
.
stubs
(
:check_file_patterns
)
sut
.
stubs
(
:check_file_patterns
)
sut
.
stubs
(
:xcodebuild
).
returns
(
"file.m:1:1: warning: direct access to objective-c's isa is deprecated"
)
sut
.
stubs
(
:xcodebuild
).
returns
(
"file.m:1:1: warning: direct access to objective-c's isa is deprecated"
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
sut
.
validate
sut
.
validate
first
=
sut
.
results
.
map
(
&
:to_s
).
first
first
=
sut
.
results
.
map
(
&
:to_s
).
first
first
.
should
.
include
"[xcodebuild]"
first
.
should
.
include
"[xcodebuild]"
...
@@ -186,6 +219,7 @@ module Pod
...
@@ -186,6 +219,7 @@ module Pod
sut
=
Validator
.
new
(
file
)
sut
=
Validator
.
new
(
file
)
sut
.
stubs
(
:build_pod
)
sut
.
stubs
(
:build_pod
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
sut
.
validate
sut
.
validate
sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/source_files.*did not match/
sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/source_files.*did not match/
sut
.
result_type
.
should
==
:error
sut
.
result_type
.
should
==
:error
...
@@ -200,6 +234,7 @@ module Pod
...
@@ -200,6 +234,7 @@ module Pod
spec
=
Specification
.
from_file
(
file
)
spec
=
Specification
.
from_file
(
file
)
sut
=
Validator
.
new
(
spec
)
sut
=
Validator
.
new
(
spec
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
sut
.
stubs
(
:build_pod
)
sut
.
stubs
(
:build_pod
)
sut
.
validate
sut
.
validate
sut
.
validated?
.
should
.
be
.
true
sut
.
validated?
.
should
.
be
.
true
...
...
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