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
663143ce
Commit
663143ce
authored
Apr 07, 2014
by
Kyle Fuller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[linter] Validate screenshot URLs return a valid image
parent
8323920b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
validator.rb
lib/cocoapods/validator.rb
+6
-1
validator_spec.rb
spec/unit/validator_spec.rb
+6
-6
No files found.
lib/cocoapods/validator.rb
View file @
663143ce
...
...
@@ -238,6 +238,8 @@ module Pod
if
resp
&&
!
resp
.
success?
warning
"The URL (
#{
url
}
) is not reachable."
end
resp
end
# Performs validations related to the `homepage` attribute.
...
...
@@ -252,7 +254,10 @@ module Pod
#
def
validate_screenshots
(
spec
)
spec
.
screenshots
.
each
do
|
screenshot
|
validate_url
(
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
...
...
spec/unit/validator_spec.rb
View file @
663143ce
...
...
@@ -121,20 +121,20 @@ module 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
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'
])
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
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
'
])
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
re was a problem validating the URL
/
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/The
screenshot .* is not a valid image
/
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