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
1174213a
Commit
1174213a
authored
Apr 15, 2014
by
clarkda
Browse files
Options
Browse Files
Download
Plain Diff
merging upstream and resolving conflicts
parents
788cb118
f28d2d4d
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
289 additions
and
51 deletions
+289
-51
CHANGELOG.md
CHANGELOG.md
+27
-0
Gemfile.lock
Gemfile.lock
+6
-6
Rakefile
Rakefile
+3
-1
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
+10
-3
sandbox.rb
lib/cocoapods/sandbox.rb
+17
-2
validator.rb
lib/cocoapods/validator.rb
+46
-7
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
+35
-0
validator_spec.rb
spec/unit/validator_spec.rb
+73
-2
No files found.
CHANGELOG.md
View file @
1174213a
...
...
@@ -26,6 +26,28 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[
Core#97
](
https://github.com/CocoaPods/Core/pull/97
)
[
Core#98
](
https://github.com/CocoaPods/Core/issues/98
)
*
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
)
*
`pod update`
prints the previous version of the updated pods.
[
Andrea Mazzini
](
https://github.com/andreamazz
)
[
#2008
](
https://github.com/CocoaPods/CocoaPods/issues/2008
)
##### Bug Fixes
*
Support HTTP redirects when linting homepage and screenshots.
[
Boris Bügling
](
https://github.com/neonichu
)
[
#2027
](
https://github.com/CocoaPods/CocoaPods/pull/2027
)
## 0.31.1
[
CocoaPods
](
https://github.com/CocoaPods/CocoaPods/compare/0.31.1...0.31.0
)
...
...
@@ -62,6 +84,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[
Robert Zuber
](
https://github.com/z00b
)
[
#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
a full lint.
[
Richard Lee
](
https://github.com/dlackty
)
...
...
Gemfile.lock
View file @
1174213a
...
...
@@ -7,7 +7,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/Core.git
revision:
5736f3cfbebe805c04e67a53729b9fa098ea8f9d
revision:
f8a920b02c19273f689c1f930af580d473c7852f
branch: master
specs:
cocoapods-core (0.31.1)
...
...
@@ -18,7 +18,7 @@ GIT
GIT
remote: https://github.com/CocoaPods/Xcodeproj.git
revision:
357d061b0b3a60fa6ac0a40cb3da6ce7689e3c9e
revision:
1ead6368b83d492ebf3194e45fb0d732632446c4
branch: master
specs:
xcodeproj (0.16.0)
...
...
@@ -59,10 +59,10 @@ GIT
GIT
remote: https://github.com/irrationalfab/PrettyBacon.git
revision:
eaf7e6c786fd5ccc6fb88e943bf7c5e6c27569a3
revision:
1eeb06f7d381acd65414b86b42fdf3538faae01c
branch: master
specs:
prettybacon (0.0.
1
)
prettybacon (0.0.
2
)
bacon (~> 1.2)
GIT
...
...
@@ -148,7 +148,7 @@ GEM
redcarpet (2.3.0)
rest-client (1.6.7)
mime-types (>= 1.16)
safe_yaml (1.0.
1
)
safe_yaml (1.0.
2
)
simplecov (0.8.2)
docile (~> 1.1.0)
multi_json
...
...
@@ -158,7 +158,7 @@ GEM
term-ansicolor (1.3.0)
tins (~> 1.0)
thor (0.19.1)
tins (1.
0.1
)
tins (1.
1.0
)
webmock (1.15.2)
addressable (>= 2.2.7)
crack (>= 0.3.2)
...
...
Rakefile
View file @
1174213a
...
...
@@ -129,6 +129,7 @@ namespace :spec do
#
task
:all
=>
:unpack_fixture_tarballs
do
ENV
[
'GENERATE_COVERAGE'
]
=
'true'
puts
"
\033
[0;32mUsing
#{
`ruby --version`
}
\033
[0m"
title
'Running the specs'
sh
"bundle exec bacon
#{
specs
(
'**/*'
)
}
"
...
...
@@ -188,7 +189,8 @@ namespace :spec do
desc
"Rebuilds integration fixtures"
task
:rebuild_integration_fixtures
do
title
'Running Integration tests'
`bundle exec bacon spec/integration.rb`
sh
'rm -rf spec/cocoapods-integration-specs/tmp'
Rake
::
Task
[
'spec:integration'
].
invoke
title
'Storing fixtures'
# Copy the files to the files produced by the specs to the after folders
...
...
lib/cocoapods.rb
View file @
1174213a
...
...
@@ -72,24 +72,3 @@ if ENV['COCOA_PODS_ENV'] == 'development'
# require 'awesome_print'
# require 'pry'
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 @
1174213a
...
...
@@ -43,11 +43,14 @@ module Pod
end
def
self
.
run
(
argv
)
help!
"You cannot run CocoaPods as root."
if
Process
.
uid
==
0
argv
=
CLAide
::
ARGV
.
new
(
argv
)
if
argv
.
flag?
(
'version'
)
UI
.
puts
VERSION
exit
0
end
super
(
argv
)
UI
.
print_warnings
end
...
...
lib/cocoapods/command/spec.rb
View file @
1174213a
...
...
@@ -480,7 +480,7 @@ Pod::Spec.new do |s|
DESC
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 ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
...
...
lib/cocoapods/external_sources.rb
View file @
1174213a
...
...
@@ -352,7 +352,8 @@ module Pod
UI
.
titled_section
(
"Fetching podspec for `
#{
name
}
`
#{
description
}
"
,
{
:verbose_prefix
=>
"-> "
})
do
podspec
=
podspec_path
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
...
...
@@ -368,10 +369,15 @@ module Pod
# @!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.
#
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"
podfile_dir
=
File
.
dirname
(
podfile_path
||
''
)
absolute_path
=
File
.
expand_path
(
path_with_ext
,
podfile_dir
)
...
...
lib/cocoapods/generator/prefix_header.rb
View file @
1174213a
...
...
@@ -40,9 +40,12 @@ module Pod
# added to the top of the prefix header. For OS X `Cocoa/Cocoa.h`
# is imported.
#
# @note Only unique prefix_header_contents are added to the prefix header.
#
# @return [String]
#
# @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
result
=
"#ifdef __OBJC__
\n
"
...
...
@@ -53,12 +56,18 @@ module Pod
result
<<
%|\n#import "#{import}"|
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
"
if
prefix_header_contents
=
file_accessor
.
spec_consumer
.
prefix_header_contents
result
<<
prefix_header_contents
result
<<
"
\n
"
end
end
file_accessors
.
each
do
|
file_accessor
|
if
prefix_header
=
file_accessor
.
prefix_header
result
<<
Pathname
(
prefix_header
).
read
end
...
...
lib/cocoapods/installer.rb
View file @
1174213a
...
...
@@ -236,7 +236,13 @@ module Pod
title_options
=
{
:verbose_prefix
=>
"-> "
.
green
}
root_specs
.
sort_by
(
&
:name
).
each
do
|
spec
|
if
pods_to_install
.
include?
(
spec
.
name
)
UI
.
titled_section
(
"Installing
#{
spec
}
"
.
green
,
title_options
)
do
if
sandbox_state
.
changed
.
include?
(
spec
.
name
)
&&
sandbox
.
manifest
previous
=
sandbox
.
manifest
.
version
(
spec
.
name
)
title
=
"Installing
#{
spec
.
name
}
#{
spec
.
version
}
(was
#{
previous
}
)"
else
title
=
"Installing
#{
spec
}
"
end
UI
.
titled_section
(
title
.
green
,
title_options
)
do
install_source_of_pod
(
spec
.
name
)
end
else
...
...
@@ -296,9 +302,10 @@ module Pod
pod_names
=
pod_targets
.
map
(
&
:pod_name
).
uniq
pod_names
.
each
do
|
pod_name
|
path
=
sandbox
.
pod_dir
(
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
if
config
.
podfile_path
...
...
lib/cocoapods/sandbox.rb
View file @
1174213a
...
...
@@ -69,6 +69,7 @@ module Pod
@head_pods
=
[]
@checkout_sources
=
{}
@development_pods
=
{}
@pods_with_absolute_path
=
[]
end
# @return [Lockfile] the manifest which contains the information about the
...
...
@@ -158,7 +159,17 @@ module Pod
root
+
root_name
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.
#
def
documentation_dir
...
...
@@ -338,11 +349,15 @@ module Pod
# @param [#to_s] path
# The local path where the Pod is stored.
#
# @param [Bool] was_absolute
# True if the specified local path was absolute.
#
# @return [void]
#
def
store_local_path
(
name
,
path
)
def
store_local_path
(
name
,
path
,
was_absolute
=
false
)
root_name
=
Specification
.
root_name
(
name
)
development_pods
[
root_name
]
=
path
.
to_s
@pods_with_absolute_path
<<
root_name
if
was_absolute
end
# @return [Hash{String=>String}] The path of the Pods with a local source
...
...
lib/cocoapods/validator.rb
View file @
1174213a
...
...
@@ -197,6 +197,7 @@ module Pod
#
def
perform_extensive_analysis
(
spec
)
validate_homepage
(
spec
)
validate_screenshots
(
spec
)
spec
.
available_platforms
.
each
do
|
platform
|
UI
.
message
"
\n\n
#{
spec
}
- Analyzing on
#{
platform
}
platform."
.
green
.
reversed
...
...
@@ -222,22 +223,60 @@ module Pod
attr_accessor
:consumer
attr_accessor
:subspec_name
# Performs validations related to the `homepage` attribute.
MAX_HTTP_REDIRECTS
=
3
# Performs validation of a URL
#
def
validate_
homepage
(
spec
)
def
validate_
url
(
url
)
require
'rest'
homepage
=
spec
.
homepage
return
unless
homepage
begin
resp
=
::
REST
.
head
(
homepage
)
redirects
=
0
resp
=
nil
loop
do
resp
=
::
REST
.
head
(
url
)
if
resp
.
status_code
>=
400
resp
=
::
REST
.
get
(
url
)
end
if
[
301
,
302
,
303
,
307
,
308
].
include?
resp
.
status_code
url
=
resp
.
headers
[
'location'
].
first
redirects
+=
1
else
break
end
break
unless
redirects
<
MAX_HTTP_REDIRECTS
end
rescue
warning
"There was a problem validating the
homepage
."
warning
"There was a problem validating the
URL
#{
url
}
."
resp
=
nil
end
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
.
compact
.
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
...
...
cocoapods-integration-specs
@
367aaee9
Subproject commit
d0378da111a5368a28c019e57e4a9f3d3d8e9d9
4
Subproject commit
367aaee9111972a40d0569155f40cf6bb63e463
4
spec/functional/command_spec.rb
View file @
1174213a
...
...
@@ -14,5 +14,9 @@ module Pod
UI
.
output
.
should
.
include
'spec/fixtures/spec-repos/master/AFNetworking'
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
spec/integration.rb
View file @
1174213a
...
...
@@ -331,6 +331,10 @@ describe "Integration" do
check
"install --no-repo-update"
,
"install_subspecs"
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
check
"install --no-repo-update"
,
"install_local_source"
end
...
...
spec/unit/generator/prefix_header_spec.rb
View file @
1174213a
...
...
@@ -21,6 +21,43 @@ module Pod
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"
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
@gen
.
generate
.
should
==
<<-
EOS
.
strip_heredoc
#ifdef __OBJC__
...
...
spec/unit/installer_spec.rb
View file @
1174213a
...
...
@@ -21,6 +21,16 @@ def generate_podfile(pods = ['JSONKit'])
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
...
...
@@ -194,6 +204,22 @@ module Pod
@installer
.
installed_specs
.
should
==
[
spec
]
end
it
"prints the previous version of a pod while updating the spec"
do
spec
=
Spec
.
new
spec
.
name
=
'RestKit'
spec
.
version
=
'2.0'
manifest
=
Lockfile
.
new
({})
manifest
.
stubs
(
:version
).
with
(
'RestKit'
).
returns
(
'1.0'
)
@installer
.
sandbox
.
stubs
(
:manifest
).
returns
(
manifest
)
@installer
.
stubs
(
:root_specs
).
returns
([
spec
])
sandbox_state
=
Installer
::
Analyzer
::
SpecsState
.
new
sandbox_state
.
changed
<<
'RestKit'
@installer
.
stubs
(
:sandbox_state
).
returns
(
sandbox_state
)
@installer
.
expects
(
:install_source_of_pod
).
with
(
'RestKit'
)
@installer
.
send
(
:install_pod_sources
)
UI
.
output
.
should
.
include
'was 1.0'
end
#--------------------------------------#
describe
"#clean"
do
...
...
@@ -247,6 +273,15 @@ module Pod
@installer
.
pods_project
.
class
.
should
==
Pod
::
Project
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
config
.
stubs
(
:podfile_path
).
returns
(
Pathname
.
new
(
'/Podfile'
))
@installer
.
send
(
:prepare_pods_project
)
...
...
spec/unit/validator_spec.rb
View file @
1174213a
...
...
@@ -75,6 +75,7 @@ module Pod
validator
=
Validator
.
new
(
file
)
validator
.
quick
=
true
validator
.
stubs
(
:validate_homepage
)
validator
.
stubs
(
:validate_screenshots
)
validator
.
validate
validator
.
validation_dir
.
should
.
be
==
Pathname
.
new
(
"/private/tmp/CocoaPods/Lint"
)
end
...
...
@@ -97,16 +98,79 @@ module Pod
it
"checks if the homepage is valid"
do
WebMock
::
API
.
stub_request
(
:head
,
/not-found/
).
to_return
(
:status
=>
404
)
WebMock
::
API
.
stub_request
(
:get
,
/not-found/
).
to_return
(
:status
=>
404
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/not-found/'
)
@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
it
"indicates if it was not able to validate the homepage"
do
WebMock
::
API
.
stub_request
(
:head
,
'banana-corp.local'
).
to_raise
(
SocketError
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/'
)
@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
it
"does not fail if the homepage redirects"
do
WebMock
::
API
.
stub_request
(
:head
,
/redirect/
).
to_return
(
:status
=>
301
,
:headers
=>
{
'Location'
=>
'http://banana-corp.local/found/'
}
)
WebMock
::
API
.
stub_request
(
:head
,
/found/
).
to_return
(
:status
=>
200
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/redirect/'
)
@sut
.
validate
@sut
.
results
.
length
.
should
.
equal
0
end
it
"does not fail if the homepage does not support HEAD"
do
WebMock
::
API
.
stub_request
(
:head
,
/page/
).
to_return
(
:status
=>
405
)
WebMock
::
API
.
stub_request
(
:get
,
/page/
).
to_return
(
:status
=>
200
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/page/'
)
@sut
.
validate
@sut
.
results
.
length
.
should
.
equal
0
end
it
"does not fail if the homepage errors on HEAD"
do
WebMock
::
API
.
stub_request
(
:head
,
/page/
).
to_return
(
:status
=>
500
)
WebMock
::
API
.
stub_request
(
:get
,
/page/
).
to_return
(
:status
=>
200
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/page/'
)
@sut
.
validate
@sut
.
results
.
length
.
should
.
equal
0
end
it
"does not follow redirects infinitely"
do
WebMock
::
API
.
stub_request
(
:head
,
/redirect/
).
to_return
(
:status
=>
301
,
:headers
=>
{
'Location'
=>
'http://banana-corp.local/redirect/'
}
)
Specification
.
any_instance
.
stubs
(
:homepage
).
returns
(
'http://banana-corp.local/redirect/'
)
@sut
.
validate
@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
...
...
@@ -114,6 +178,7 @@ module Pod
file
=
write_podspec
(
stub_podspec
)
sut
=
Validator
.
new
(
file
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
sut
.
no_clean
=
true
sut
.
validate
sut
.
validation_dir
.
should
.
exist
...
...
@@ -123,6 +188,7 @@ module Pod
file
=
write_podspec
(
stub_podspec
)
sut
=
Validator
.
new
(
file
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
sut
.
expects
(
:install_pod
).
twice
sut
.
expects
(
:build_pod
).
twice
sut
.
expects
(
:check_file_patterns
).
twice
...
...
@@ -132,6 +198,7 @@ module Pod
it
"uses the deployment target of the specification"
do
sut
=
Validator
.
new
(
podspec_path
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
podfile
=
sut
.
send
(
:podfile_from_spec
,
:ios
,
'5.0'
)
dependency
=
podfile
.
target_definitions
[
'Pods'
].
dependencies
.
first
dependency
.
external_source
.
has_key?
(
:podspec
).
should
.
be
.
true
...
...
@@ -140,6 +207,7 @@ module Pod
it
"respects the local option"
do
sut
=
Validator
.
new
(
podspec_path
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
podfile
=
sut
.
send
(
:podfile_from_spec
,
:ios
,
'5.0'
)
deployment_target
=
podfile
.
target_definitions
[
'Pods'
].
platform
.
deployment_target
deployment_target
.
to_s
.
should
==
"5.0"
...
...
@@ -150,6 +218,7 @@ module Pod
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
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
sut
.
validate
first
=
sut
.
results
.
map
(
&
:to_s
).
first
first
.
should
.
include
"[xcodebuild]"
...
...
@@ -161,6 +230,7 @@ module Pod
sut
=
Validator
.
new
(
file
)
sut
.
stubs
(
:build_pod
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
sut
.
validate
sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/source_files.*did not match/
sut
.
result_type
.
should
==
:error
...
...
@@ -175,6 +245,7 @@ module Pod
spec
=
Specification
.
from_file
(
file
)
sut
=
Validator
.
new
(
spec
)
sut
.
stubs
(
:validate_homepage
)
sut
.
stubs
(
:validate_screenshots
)
sut
.
stubs
(
:build_pod
)
sut
.
validate
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