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
9cc299a9
Commit
9cc299a9
authored
Apr 27, 2014
by
Kyle Fuller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[linter] Check social_media_url is valid HTTP URL
parent
2659252f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
2 deletions
+36
-2
CHANGELOG.md
CHANGELOG.md
+7
-0
validator.rb
lib/cocoapods/validator.rb
+7
-0
validator_spec.rb
spec/unit/validator_spec.rb
+22
-2
No files found.
CHANGELOG.md
View file @
9cc299a9
...
@@ -4,6 +4,13 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
...
@@ -4,6 +4,13 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
## Master
## Master
##### Enhancements
*
Validate the reachability of social media URLs in podspecs while linting a
specification.
[
Kyle Fuller
](
https://github.com/kylef
)
[
#2025
](
https://github.com/CocoaPods/CocoaPods/issues/2025
)
##### Bug Fixes
##### Bug Fixes
*
Fixed support for file references in the workspace generated by CocoaPods.
*
Fixed support for file references in the workspace generated by CocoaPods.
...
...
lib/cocoapods/validator.rb
View file @
9cc299a9
...
@@ -198,6 +198,7 @@ module Pod
...
@@ -198,6 +198,7 @@ module Pod
def
perform_extensive_analysis
(
spec
)
def
perform_extensive_analysis
(
spec
)
validate_homepage
(
spec
)
validate_homepage
(
spec
)
validate_screenshots
(
spec
)
validate_screenshots
(
spec
)
validate_social_media_url
(
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
...
@@ -256,6 +257,12 @@ module Pod
...
@@ -256,6 +257,12 @@ module Pod
end
end
end
end
# Performs validations related to the `social_media_url` attribute.
#
def
validate_social_media_url
(
spec
)
validate_url
(
spec
.
social_media_url
)
if
spec
.
social_media_url
end
def
setup_validation_environment
def
setup_validation_environment
validation_dir
.
rmtree
if
validation_dir
.
exist?
validation_dir
.
rmtree
if
validation_dir
.
exist?
validation_dir
.
mkpath
validation_dir
.
mkpath
...
...
spec/unit/validator_spec.rb
View file @
9cc299a9
...
@@ -104,12 +104,12 @@ module Pod
...
@@ -104,12 +104,12 @@ module Pod
@sut
.
stubs
(
:build_pod
)
@sut
.
stubs
(
:build_pod
)
@sut
.
stubs
(
:check_file_patterns
)
@sut
.
stubs
(
:check_file_patterns
)
@sut
.
stubs
(
:tear_down_validation_environment
)
@sut
.
stubs
(
:tear_down_validation_environment
)
WebMock
::
API
.
stub_request
(
:head
,
/not-found/
).
to_return
(
:status
=>
404
)
WebMock
::
API
.
stub_request
(
:get
,
/not-found/
).
to_return
(
:status
=>
404
)
end
end
describe
"Homepage validation"
do
describe
"Homepage validation"
do
it
"checks if the homepage is valid"
do
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/'
)
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 URL (.*) is not reachable/
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/The URL (.*) is not reachable/
...
@@ -189,6 +189,26 @@ module Pod
...
@@ -189,6 +189,26 @@ module Pod
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/The screenshot .* is not a valid image/
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/The screenshot .* is not a valid image/
end
end
end
end
describe
"social media URL validation"
do
before
do
@sut
.
stubs
(
:validate_homepage
)
end
it
"checks if the social media URL is valid"
do
Specification
.
any_instance
.
stubs
(
:social_media_urlon_url
).
returns
(
'http://banana-corp.local/'
)
WebMock
::
API
.
stub_request
(
:head
,
/banana-corp.local/
).
to_return
(
:status
=>
200
)
@sut
.
validate
@sut
.
results
.
should
.
be
.
empty?
end
it
"should fail validation if it wasn't able to validate the URL"
do
Specification
.
any_instance
.
stubs
(
:social_media_url
).
returns
(
'http://banana-corp.local/not-found/'
)
WebMock
::
API
.
stub_request
(
:head
,
/banana-corp.local/
).
to_return
(
:status
=>
404
)
@sut
.
validate
@sut
.
results
.
map
(
&
:to_s
).
first
.
should
.
match
/The URL \(.*\) is not reachable/
end
end
end
end
it
"respects the no clean option"
do
it
"respects the no clean option"
do
...
...
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