Commit 136672ff authored by Samuel Giddins's avatar Samuel Giddins

[AbstractExternalSource] Add specs for validating pods

parent 9d6900de
...@@ -154,7 +154,7 @@ module Pod ...@@ -154,7 +154,7 @@ module Pod
end end
def validate_podspec(podspec) def validate_podspec(podspec)
validator = Validator.new(podspec, []) validator = validator_for_podspec(podspec)
validator.quick = true validator.quick = true
validator.allow_warnings = true validator.allow_warnings = true
validator.ignore_public_only_results = true validator.ignore_public_only_results = true
...@@ -165,6 +165,10 @@ module Pod ...@@ -165,6 +165,10 @@ module Pod
raise Informative, "The `#{name}` pod failed to validate due to #{validator.failure_reason}:\n#{validator.results_message}" raise Informative, "The `#{name}` pod failed to validate due to #{validator.failure_reason}:\n#{validator.results_message}"
end end
end end
def validator_for_podspec(podspec)
Validator.new(podspec, [])
end
end end
end end
end end
...@@ -32,6 +32,7 @@ module Pod ...@@ -32,6 +32,7 @@ module Pod
describe 'Subclasses helpers' do describe 'Subclasses helpers' do
it 'pre-downloads the Pod and stores the relevant information in the sandbox' do it 'pre-downloads the Pod and stores the relevant information in the sandbox' do
@subject.expects(:validate_podspec).with { |spec| spec.name.should == 'Reachability' }
@subject.send(:pre_download, config.sandbox) @subject.send(:pre_download, config.sandbox)
path = config.sandbox.specifications_root + 'Reachability.podspec.json' path = config.sandbox.specifications_root + 'Reachability.podspec.json'
path.should.exist? path.should.exist?
...@@ -43,6 +44,39 @@ module Pod ...@@ -43,6 +44,39 @@ module Pod
}, },
} }
end end
describe 'podspec validation' do
before do
@podspec = Pod::Specification.from_file(fixture('spec-repos') + 'master/Specs/JSONKit/1.4/JSONKit.podspec.json')
end
it 'returns a validator for the given podspec' do
validator = @subject.send(:validator_for_podspec, @podspec)
validator.spec.should == @podspec
end
before do
@validator = mock('Validator')
@validator.expects(:quick=).with(true)
@validator.expects(:allow_warnings=).with(true)
@validator.expects(:ignore_public_only_results=).with(true)
@validator.expects(:validate)
@subject.stubs(:validator_for_podspec).returns(@validator)
end
it 'validates with the correct settings' do
@validator.expects(:validated?).returns(true)
@subject.send(:validate_podspec, @podspec)
end
it 'raises when validation fails' do
@validator.expects(:validated?).returns(false)
@validator.stubs(:results_message).returns('results_message')
@validator.stubs(:failure_reason).returns('failure_reason')
should.raise(Informative) { @subject.send(:validate_podspec, @podspec) }.
message.should.include "The `Reachability` pod failed to validate due to failure_reason:\nresults_message"
end
end
end end
end end
end end
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