Commit 867d055b authored by Samuel Giddins's avatar Samuel Giddins

Fix validator specs

parent f97108e5
......@@ -687,8 +687,6 @@ module Pod
raise Pod::Informative, 'The `Pods` directory is out-of-date, you must run `pod install`'
end
create_file_accessors
aggregate_targets
end
end
......
......@@ -261,9 +261,10 @@ module Pod
unless podspec.exist?
raise Informative, "No podspec found for `#{name}` in #{podspec}"
end
spec = Specification.from_file(podspec)
FileUtils.copy(podspec, output_path)
when Specification
raise ArgumentError unless json
raise ArgumentError, "can only store Specification objects as json" unless json
output_path.open('w') { |f| f.puts(podspec.to_pretty_json) }
spec = podspec.dup
else
......
......@@ -185,10 +185,10 @@ module Pod
end
it 'validates specs as frameworks by default' do
Validator.any_instance.expects(:podfile_from_spec).with(:ios, '8.0', true, []).times(3)
Validator.any_instance.expects(:podfile_from_spec).with(:osx, nil, true, []).twice
Validator.any_instance.expects(:podfile_from_spec).with(:watchos, nil, true, []).twice
Validator.any_instance.expects(:podfile_from_spec).with(:tvos, nil, true, []).twice
Validator.any_instance.expects(:podfile_from_spec).with(:ios, '8.0', true, []).times(3).returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:osx, nil, true, []).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:watchos, nil, true, []).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:tvos, nil, true, []).twice.returns(stub('Podfile'))
cmd = command('repo', 'push', 'master')
# Git push will throw an exception here since this is a local custom git repo. All we care is the validator
......@@ -199,10 +199,10 @@ module Pod
end
it 'validates specs as libraries if requested' do
Validator.any_instance.expects(:podfile_from_spec).with(:ios, nil, false, []).times(3)
Validator.any_instance.expects(:podfile_from_spec).with(:osx, nil, false, []).twice
Validator.any_instance.expects(:podfile_from_spec).with(:watchos, nil, false, []).twice
Validator.any_instance.expects(:podfile_from_spec).with(:tvos, nil, false, []).twice
Validator.any_instance.expects(:podfile_from_spec).with(:ios, nil, false, []).times(3).returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:osx, nil, false, []).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:watchos, nil, false, []).twice.returns(stub('Podfile'))
Validator.any_instance.expects(:podfile_from_spec).with(:tvos, nil, false, []).twice.returns(stub('Podfile'))
cmd = command('repo', 'push', 'master', '--use-libraries')
# Git push will throw an exception here since this is a local custom git repo. All we care is the validator
......
......@@ -1040,6 +1040,7 @@ module Pod
@sandbox_manifest = Pod::Lockfile.new(@lockfile.internal_data.deep_dup)
@analyzer.sandbox.manifest = @sandbox_manifest
@analyzer.sandbox.stubs(:specification).with('BananaLib').returns(stub)
@analyzer.sandbox.stubs(:specification_path).with('BananaLib').returns(stub)
pod_dir = stub
pod_dir.stubs(:directory?).returns(true)
@analyzer.sandbox.stubs(:pod_dir).with('BananaLib').returns(pod_dir)
......
......@@ -107,13 +107,8 @@ module Pod
it 'loads the stored specification from the original path' do
spec_file = fixture('banana-lib/BananaLib.podspec')
spec = Specification.from_file(spec_file)
Specification.expects(:from_file).with do
Dir.pwd == fixture('banana-lib').to_s
end.once.returns(spec)
Specification.expects(:from_file).with do |path|
path == spec_file
end.once.returns(spec)
Specification.expects(:from_file).with(spec_file).once.returns(spec)
@sandbox.store_podspec('BananaLib', spec_file)
@sandbox.store_local_path('BananaLib', spec_file)
......
......@@ -360,12 +360,14 @@ module Pod
s.ios.deployment_target = '7.0'
end
validator.spec.stubs(:subspecs).returns([subspec])
validator.expects(:podfile_from_spec).with(:osx, nil, nil, []).once
validator.expects(:podfile_from_spec).with(:ios, nil, nil, []).once
validator.expects(:podfile_from_spec).with(:ios, '7.0', nil, []).once
validator.expects(:podfile_from_spec).with(:tvos, nil, nil, []).once
validator.expects(:podfile_from_spec).with(:watchos, nil, nil, []).once
validator.expects(:podfile_from_spec).with(:osx, nil, nil, []).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:ios, nil, nil, []).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:ios, '7.0', nil, []).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:tvos, nil, nil, []).once.returns(stub('Podfile'))
validator.expects(:podfile_from_spec).with(:watchos, nil, nil, []).once.returns(stub('Podfile'))
validator.send(:perform_extensive_analysis, validator.spec)
validator.results_message.strip.should.be.empty
end
describe '#podfile_from_spec' do
......@@ -799,11 +801,13 @@ module Pod
setup_validator
@validator.expects(:podfile_from_spec).with(:osx, nil, true, []).once
@validator.expects(:podfile_from_spec).with(:ios, '8.0', true, []).once
@validator.expects(:podfile_from_spec).with(:tvos, nil, true, []).once
@validator.expects(:podfile_from_spec).with(:watchos, nil, true, []).once
@validator.expects(:podfile_from_spec).with(:osx, nil, true, []).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:ios, '8.0', true, []).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:tvos, nil, true, []).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:watchos, nil, true, []).once.returns(stub('Podfile'))
@validator.send(:perform_extensive_analysis, @validator.spec)
@validator.results_message.strip.should.be.empty
end
it 'lint as a static library if specified' do
......@@ -811,11 +815,13 @@ module Pod
setup_validator
@validator.expects(:podfile_from_spec).with(:osx, nil, false, []).once
@validator.expects(:podfile_from_spec).with(:ios, nil, false, []).once
@validator.expects(:podfile_from_spec).with(:tvos, nil, false, []).once
@validator.expects(:podfile_from_spec).with(:watchos, nil, false, []).once
@validator.expects(:podfile_from_spec).with(:osx, nil, false, []).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:ios, nil, false, []).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:tvos, nil, false, []).once.returns(stub('Podfile'))
@validator.expects(:podfile_from_spec).with(:watchos, nil, false, []).once.returns(stub('Podfile'))
@validator.send(:perform_extensive_analysis, @validator.spec)
@validator.results_message.strip.should.be.empty
end
it 'shows an error when performing extensive analysis on a test spec' 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