Commit 9ab707ef authored by Kyle Fuller's avatar Kyle Fuller

[linter] Check docset_url is valid HTTP URL

parent 2f444617
...@@ -6,8 +6,8 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides ...@@ -6,8 +6,8 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
##### Enhancements ##### Enhancements
* Validate the reachability of social_media_url, documentation_url in * Validate the reachability of social_media_url, documentation_url and
podspecs while linting a specification. docset_url in podspecs we while linting a specification.
[Kyle Fuller](https://github.com/kylef) [Kyle Fuller](https://github.com/kylef)
[#2025](https://github.com/CocoaPods/CocoaPods/issues/2025) [#2025](https://github.com/CocoaPods/CocoaPods/issues/2025)
......
...@@ -200,6 +200,7 @@ module Pod ...@@ -200,6 +200,7 @@ module Pod
validate_screenshots(spec) validate_screenshots(spec)
validate_social_media_url(spec) validate_social_media_url(spec)
validate_documentation_url(spec) validate_documentation_url(spec)
validate_docset_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
...@@ -270,6 +271,12 @@ module Pod ...@@ -270,6 +271,12 @@ module Pod
validate_url(spec.documentation_url) if spec.documentation_url validate_url(spec.documentation_url) if spec.documentation_url
end end
# Performs validations related to the `docset_url` attribute.
#
def validate_docset_url(spec)
validate_url(spec.docset_url) if spec.docset_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
......
...@@ -228,6 +228,25 @@ module Pod ...@@ -228,6 +228,25 @@ module Pod
@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/
end end
end end
describe "docset URL validation" do
before do
@sut.stubs(:validate_homepage)
end
it "checks if the docset URL is valid" do
Specification.any_instance.stubs(:docset_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(:docset_url).returns('http://banana-corp.local/not-found')
@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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment