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
e7de2605
Commit
e7de2605
authored
Apr 07, 2014
by
Kyle Fuller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[linter] Validate screenshots are valid
Closes #2010
parent
2b500a99
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
9 deletions
+56
-9
CHANGELOG.md
CHANGELOG.md
+5
-0
validator.rb
lib/cocoapods/validator.rb
+22
-7
validator_spec.rb
spec/unit/validator_spec.rb
+29
-2
No files found.
CHANGELOG.md
View file @
e7de2605
...
...
@@ -20,6 +20,11 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
[
Piet Brauer
](
https://github.com/pietbrauer
)
[
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
)
## 0.31.1
[
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
)
...
...
lib/cocoapods/validator.rb
View file @
e7de2605
...
...
@@ -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,36 @@ module Pod
attr_accessor
:consumer
attr_accessor
:subspec_name
# Performs validation
s related to the `homepage` attribute.
# 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
)
resp
=
::
REST
.
head
(
url
)
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
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
|
validate_url
(
screenshot
)
end
end
...
...
spec/unit/validator_spec.rb
View file @
e7de2605
...
...
@@ -99,14 +99,41 @@ module Pod
WebMock
::
API
.
stub_request
(
:head
,
/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
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
)
end
it
"checks if the screenshots are valid"
do
WebMock
::
API
.
stub_request
(
:head
,
/banana-corp.local/
).
to_return
(
:status
=>
200
)
Specification
.
any_instance
.
stubs
(
:screenshots
).
returns
([
'http://banana-corp.local/first.png'
,
'http://banana-corp.local/second.png'
])
@sut
.
validate
@sut
.
results
.
should
.
be
.
empty?
end
it
"should fail if any of the screenshots is not valid"
do
WebMock
::
API
.
stub_request
(
:head
,
/not-found/
).
to_raise
(
SocketError
)
Specification
.
any_instance
.
stubs
(
:screenshots
).
returns
([
'http://banana-corp.local/first.png'
,
'http://banana-corp.local/not-found/second.png'
])
@sut
.
validate
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/There was a problem validating the URL/
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