Commit 2f444617 authored by Kyle Fuller's avatar Kyle Fuller

[linter] Check documentation_url is valid HTTP URL

parent 9cc299a9
......@@ -6,8 +6,8 @@ To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides
##### Enhancements
* Validate the reachability of social media URLs in podspecs while linting a
specification.
* Validate the reachability of social_media_url, documentation_url in
podspecs while linting a specification.
[Kyle Fuller](https://github.com/kylef)
[#2025](https://github.com/CocoaPods/CocoaPods/issues/2025)
......
......@@ -199,6 +199,7 @@ module Pod
validate_homepage(spec)
validate_screenshots(spec)
validate_social_media_url(spec)
validate_documentation_url(spec)
spec.available_platforms.each do |platform|
UI.message "\n\n#{spec} - Analyzing on #{platform} platform.".green.reversed
......@@ -263,6 +264,12 @@ module Pod
validate_url(spec.social_media_url) if spec.social_media_url
end
# Performs validations related to the `documentation_url` attribute.
#
def validate_documentation_url(spec)
validate_url(spec.documentation_url) if spec.documentation_url
end
def setup_validation_environment
validation_dir.rmtree if validation_dir.exist?
validation_dir.mkpath
......
......@@ -209,6 +209,25 @@ module Pod
@sut.results.map(&:to_s).first.should.match /The URL \(.*\) is not reachable/
end
end
describe "documentation URL validation" do
before do
@sut.stubs(:validate_homepage)
end
it "checks if the documentation URL is valid" do
Specification.any_instance.stubs(:documentation_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(:documentation_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
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