Commit 8c920151 authored by Kyle Fuller's avatar Kyle Fuller

[Specs] Stop using `sut`

parent cdf94bda
......@@ -356,14 +356,14 @@ module Pod
before do
# TODO Use class methods
@sut = Command::Spec.new(CLAide::ARGV.new([]))
@command = Command::Spec.new(CLAide::ARGV.new([]))
end
describe '#get_path_of_spec' do
it 'returns the path of the specification with the given name' do
path = @sut.send(:get_path_of_spec, 'AFNetworking')
path = @command.send(:get_path_of_spec, 'AFNetworking')
path.should == fixture('spec-repos') + 'master/Specs/AFNetworking/2.4.1/AFNetworking.podspec.json'
end
......@@ -373,16 +373,16 @@ module Pod
it 'should return a valid index for the given array' do
UI.next_input = "1\n"
index = @sut.send(:choose_from_array, %w(item1 item2 item3), 'A message')
index = @command.send(:choose_from_array, %w(item1 item2 item3), 'A message')
UI.output.should.include "1: item1\n2: item2\n3: item3\nA message\n"
index.should == 0
end
it 'should raise when the index is out of bounds' do
UI.next_input = "4\n"
lambda { @sut.send(:choose_from_array, %w(item1 item2 item3), 'A message') }.should.raise Pod::Informative
lambda { @command.send(:choose_from_array, %w(item1 item2 item3), 'A message') }.should.raise Pod::Informative
UI.next_input = "0\n"
lambda { @sut.send(:choose_from_array, %w(item1 item2 item3), 'A message') }.should.raise Pod::Informative
lambda { @command.send(:choose_from_array, %w(item1 item2 item3), 'A message') }.should.raise Pod::Informative
end
end
......
......@@ -3,7 +3,7 @@ require File.expand_path('../../spec_helper', __FILE__)
module Pod
describe Config do
before do
@sut = Config.new(false)
@config = Config.new(false)
end
#-------------------------------------------------------------------------#
......@@ -11,35 +11,35 @@ module Pod
describe 'In general' do
it 'returns the singleton config instance' do
@sut.should.be.instance_of Config
@config.should.be.instance_of Config
end
it 'returns the path to the home dir' do
@sut.home_dir.should == Pathname.new('~/.cocoapods').expand_path
@config.home_dir.should == Pathname.new('~/.cocoapods').expand_path
end
it 'returns the path to the spec-repos dir' do
@sut.repos_dir.should == Pathname.new('~/.cocoapods/repos').expand_path
@config.repos_dir.should == Pathname.new('~/.cocoapods/repos').expand_path
end
it 'returns the path to the templates dir' do
@sut.templates_dir.should == Pathname.new('~/.cocoapods/templates').expand_path
@config.templates_dir.should == Pathname.new('~/.cocoapods/templates').expand_path
end
it 'returns the path of the default podfiles' do
@sut.default_podfile_path.should == Pathname.new('~/.cocoapods/templates/Podfile.default').expand_path
@sut.default_test_podfile_path.should == Pathname.new('~/.cocoapods/templates/Podfile.test').expand_path
@config.default_podfile_path.should == Pathname.new('~/.cocoapods/templates/Podfile.default').expand_path
@config.default_test_podfile_path.should == Pathname.new('~/.cocoapods/templates/Podfile.test').expand_path
end
it 'allows to specify the home dir with an environment variable' do
ENV['CP_HOME_DIR'] = '~/custom_home_dir'
@sut.home_dir.should == Pathname.new('~/custom_home_dir').expand_path
@config.home_dir.should == Pathname.new('~/custom_home_dir').expand_path
ENV.delete('CP_HOME_DIR')
end
it 'allows to specify the repos dir with an environment variable' do
ENV['CP_REPOS_DIR'] = '~/custom_repos_dir'
@sut.repos_dir.should == Pathname.new('~/custom_repos_dir').expand_path
@config.repos_dir.should == Pathname.new('~/custom_repos_dir').expand_path
ENV.delete('CP_REPOS_DIR')
end
end
......@@ -51,7 +51,7 @@ module Pod
it 'returns the working directory as the installation root if a Podfile can be found' do
Dir.chdir(temporary_directory) do
File.open('Podfile', 'w') {}
@sut.installation_root.should == temporary_directory
@config.installation_root.should == temporary_directory
end
end
......@@ -61,54 +61,54 @@ module Pod
sub_dir = temporary_directory + 'sub_dir'
sub_dir.mkpath
Dir.chdir(sub_dir) do
@sut.installation_root.should == temporary_directory
@config.installation_root.should == temporary_directory
end
end
end
it 'it returns the working directory as the installation root if no Podfile can be found' do
Dir.chdir(temporary_directory) do
@sut.installation_root.should == temporary_directory
@config.installation_root.should == temporary_directory
end
end
before do
@sut.installation_root = temporary_directory
@config.installation_root = temporary_directory
end
it 'returns the path to the project root' do
@sut.installation_root.should == temporary_directory
@config.installation_root.should == temporary_directory
end
it 'returns the path to the project Podfile if it exists' do
(temporary_directory + 'Podfile').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'Podfile'
@config.podfile_path.should == temporary_directory + 'Podfile'
end
it 'can detect yaml Podfiles' do
(temporary_directory + 'CocoaPods.podfile.yaml').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'CocoaPods.podfile.yaml'
@config.podfile_path.should == temporary_directory + 'CocoaPods.podfile.yaml'
end
it 'can detect files named `CocoaPods.podfile`' do
(temporary_directory + 'CocoaPods.podfile').open('w') { |f| f << '# Yo' }
@sut.podfile_path.should == temporary_directory + 'CocoaPods.podfile'
@config.podfile_path.should == temporary_directory + 'CocoaPods.podfile'
end
it 'returns the path to the Pods directory that holds the dependencies' do
@sut.sandbox_root.should == temporary_directory + 'Pods'
@config.sandbox_root.should == temporary_directory + 'Pods'
end
it 'returns the Podfile path' do
Dir.chdir(temporary_directory) do
File.open('Podfile', 'w') {}
@sut.podfile_path.should == temporary_directory + 'Podfile'
@config.podfile_path.should == temporary_directory + 'Podfile'
end
end
it 'returns nils if the Podfile if no paths exists' do
Dir.chdir(temporary_directory) do
@sut.podfile_path.should.nil?
@config.podfile_path.should.nil?
end
end
......@@ -116,12 +116,12 @@ module Pod
Dir.chdir(temporary_directory) do
File.open('Podfile', 'w') {}
File.open('Podfile.lock', 'w') {}
@sut.lockfile_path.should == temporary_directory + 'Podfile.lock'
@config.lockfile_path.should == temporary_directory + 'Podfile.lock'
end
end
it 'returns the search index file' do
@sut.search_index_file.to_s.should.end_with?('search_index.yaml')
@config.search_index_file.to_s.should.end_with?('search_index.yaml')
end
end
......@@ -131,19 +131,19 @@ module Pod
describe 'Default settings' do
it 'prints out normal information' do
@sut.should.not.be.silent
@config.should.not.be.silent
end
it 'does not print verbose information' do
@sut.should.not.be.verbose
@config.should.not.be.verbose
end
it 'cleans SCM dirs in dependency checkouts' do
@sut.should.clean
@config.should.clean
end
it 'returns the cache root' do
@sut.cache_root.should == Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods'))
@config.cache_root.should == Pathname.new(File.join(ENV['HOME'], 'Library/Caches/CocoaPods'))
end
end
......@@ -152,13 +152,13 @@ module Pod
describe 'Private helpers' do
it 'returns the path of the user settings file' do
@sut.send(:user_settings_file).should == Pathname.new('~/.cocoapods/config.yaml').expand_path
@config.send(:user_settings_file).should == Pathname.new('~/.cocoapods/config.yaml').expand_path
end
it 'can be configured with a hash' do
hash = { :verbose => true }
@sut.send(:configure_with, hash)
@sut.should.be.verbose
@config.send(:configure_with, hash)
@config.should.be.verbose
end
#----------------------------------------#
......@@ -168,26 +168,26 @@ module Pod
it 'detects the CocoaPods.podfile.yaml file' do
expected = temporary_directory + 'CocoaPods.podfile.yaml'
File.open(expected, 'w') {}
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path = @config.send(:podfile_path_in_dir, temporary_directory)
path.should == expected
end
it 'detects the CocoaPods.podfile file' do
expected = temporary_directory + 'CocoaPods.podfile'
File.open(expected, 'w') {}
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path = @config.send(:podfile_path_in_dir, temporary_directory)
path.should == expected
end
it 'detects the Podfile file' do
expected = temporary_directory + 'Podfile'
File.open(expected, 'w') {}
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path = @config.send(:podfile_path_in_dir, temporary_directory)
path.should == expected
end
it 'returns nils if the Podfile is not available' do
path = @sut.send(:podfile_path_in_dir, temporary_directory)
path = @config.send(:podfile_path_in_dir, temporary_directory)
path.should.nil?
end
......
......@@ -77,7 +77,7 @@ module Pod
describe 'Private Helpers' do
before do
@sut = PrivatePodXCConfig.new(stub, stub)
@config = PrivatePodXCConfig.new(stub, stub)
end
#----------------------------------------#
......@@ -87,21 +87,21 @@ module Pod
it 'appends to the values of the keys of the destination the value of the keys of the source' do
source_config = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/MyPod' }
destination_config = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders' }
result = @sut.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result = @config.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result.should == { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders ${PREFIX_HEADER_SEARCH_PATHS}' }
end
it 'uses the key of the destination xcconfig if not present in the source' do
source_config = {}
destination_config = { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders' }
result = @sut.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result = @config.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result.should == { 'HEADER_SEARCH_PATHS' => '${PODS_ROOT}/BuildHeaders' }
end
it 'preserves any value of the source not present in the destination' do
source_config = { 'EXCLUDED_SOURCE_FILE_NAMES' => 'ZBarReaderViewImpl_Simulator.m' }
destination_config = {}
result = @sut.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result = @config.send(:add_xcconfig_namespaced_keys, source_config, destination_config, 'PREFIX_')
result.should == { 'EXCLUDED_SOURCE_FILE_NAMES' => '${PREFIX_EXCLUDED_SOURCE_FILE_NAMES}' }
end
......@@ -112,12 +112,12 @@ module Pod
describe '#conditional_less_key' do
it 'returns the key without the xcconfig conditional syntax if present' do
result = @sut.send(:conditional_less_key, 'EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*][arch=*]')
result = @config.send(:conditional_less_key, 'EXCLUDED_SOURCE_FILE_NAMES[sdk=iphoneos*][arch=*]')
result.should == 'EXCLUDED_SOURCE_FILE_NAMES'
end
it 'returns the key as it is if no conditional syntax is present' do
result = @sut.send(:conditional_less_key, 'EXCLUDED_SOURCE_FILE_NAMES')
result = @config.send(:conditional_less_key, 'EXCLUDED_SOURCE_FILE_NAMES')
result.should == 'EXCLUDED_SOURCE_FILE_NAMES'
end
......
......@@ -47,40 +47,40 @@ module Pod
describe 'Quick mode' do
it 'validates a correct podspec' do
sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.quick = true
sut.validate
sut.results.should == []
sut.validated?.should.be.true
validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
validator.quick = true
validator.validate
validator.results.should == []
validator.validated?.should.be.true
end
it 'lints the podspec during validation' do
podspec = stub_podspec(/.*name.*/, '"name": "TEST",')
file = write_podspec(podspec)
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.quick = true
sut.validate
sut.results.map(&:to_s).first.should.match /should match the name/
sut.validated?.should.be.false
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.quick = true
validator.validate
validator.results.map(&:to_s).first.should.match /should match the name/
validator.validated?.should.be.false
end
it 'respects quick mode' do
file = write_podspec(stub_podspec)
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.quick = true
sut.expects(:perform_extensive_analysis).never
sut.validate
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.quick = true
validator.expects(:perform_extensive_analysis).never
validator.validate
end
it 'respects the allow warnings option' do
podspec = stub_podspec(/.*summary.*/, '"summary": "A short description of",')
file = write_podspec(podspec)
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.quick = true
sut.allow_warnings = true
sut.validate
sut.results.map(&:to_s).first.should.match /summary.*meaningful/
sut.validated?.should.be.true
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.quick = true
validator.allow_warnings = true
validator.validate
validator.results.map(&:to_s).first.should.match /summary.*meaningful/
validator.validated?.should.be.true
end
it 'handles symlinks' do
......@@ -99,11 +99,11 @@ module Pod
describe 'URL validation' do
before do
@sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
@sut.stubs(:install_pod)
@sut.stubs(:build_pod)
@sut.stubs(:check_file_patterns)
@sut.stubs(:tear_down_validation_environment)
@validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
@validator.stubs(:install_pod)
@validator.stubs(:build_pod)
@validator.stubs(:check_file_patterns)
@validator.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
......@@ -111,15 +111,15 @@ module Pod
describe 'Homepage validation' do
it 'checks if the homepage is valid' do
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/not-found/')
@sut.validate
@sut.results.map(&:to_s).first.should.match /The URL (.*) is not reachable/
@validator.validate
@validator.results.map(&:to_s).first.should.match /The URL (.*) is not reachable/
end
it 'indicates if it was not able to validate the homepage' do
WebMock::API.stub_request(:head, 'banana-corp.local').to_raise(SocketError)
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/')
@sut.validate
@sut.results.map(&:to_s).first.should.match /There was a problem validating the URL/
@validator.validate
@validator.results.map(&:to_s).first.should.match /There was a problem validating the URL/
end
it 'does not fail if the homepage redirects' do
......@@ -127,24 +127,24 @@ module Pod
:status => 301, :headers => { 'Location' => 'http://banana-corp.local/found/' })
WebMock::API.stub_request(:head, /found/).to_return(:status => 200)
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/redirect/')
@sut.validate
@sut.results.length.should.equal 0
@validator.validate
@validator.results.length.should.equal 0
end
it 'does not fail if the homepage does not support HEAD' do
WebMock::API.stub_request(:head, /page/).to_return(:status => 405)
WebMock::API.stub_request(:get, /page/).to_return(:status => 200)
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/page/')
@sut.validate
@sut.results.length.should.equal 0
@validator.validate
@validator.results.length.should.equal 0
end
it 'does not fail if the homepage errors on HEAD' do
WebMock::API.stub_request(:head, /page/).to_return(:status => 500)
WebMock::API.stub_request(:get, /page/).to_return(:status => 200)
Specification.any_instance.stubs(:homepage).returns('http://banana-corp.local/page/')
@sut.validate
@sut.results.length.should.equal 0
@validator.validate
@validator.results.length.should.equal 0
end
it 'does not follow redirects infinitely' do
......@@ -153,8 +153,8 @@ module Pod
:headers => { 'Location' => 'http://banana-corp.local/redirect/' })
Specification.any_instance.stubs(:homepage).returns(
'http://banana-corp.local/redirect/')
@sut.validate
@sut.results.map(&:to_s).first.should.match /The URL \(.*\) is not reachable/
@validator.validate
@validator.results.map(&:to_s).first.should.match /The URL \(.*\) is not reachable/
end
it 'supports relative redirects' do
......@@ -165,14 +165,14 @@ module Pod
:status => 200)
Specification.any_instance.stubs(:homepage).returns(
'http://banana-corp.local/redirect')
@sut.validate
@sut.results.length.should.equal 0
@validator.validate
@validator.results.length.should.equal 0
end
end
describe 'Screenshot validation' do
before do
@sut.stubs(:validate_homepage)
@validator.stubs(:validate_homepage)
WebMock::API.
stub_request(:head, 'banana-corp.local/valid-image.png').
to_return(
......@@ -184,101 +184,101 @@ module Pod
it 'checks if the screenshots are valid' do
Specification.any_instance.stubs(:screenshots).
returns(['http://banana-corp.local/valid-image.png'])
@sut.validate
@sut.results.should.be.empty?
@validator.validate
@validator.results.should.be.empty?
end
it 'should fail if any of the screenshots URLS do not return an image' do
WebMock::API.stub_request(:head, 'banana-corp.local/').to_return(:status => 200)
Specification.any_instance.stubs(:screenshots).returns(['http://banana-corp.local/valid-image.png', 'http://banana-corp.local/'])
@sut.validate
@sut.results.map(&:to_s).first.should.match /The screenshot .* is not a valid image/
@validator.validate
@validator.results.map(&:to_s).first.should.match /The screenshot .* is not a valid image/
end
end
describe 'social media URL validation' do
before do
@sut.stubs(:validate_homepage)
@validator.stubs(:validate_homepage)
end
it 'checks if the social media URL is valid' do
Specification.any_instance.stubs(:social_media_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?
@validator.validate
@validator.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/
@validator.validate
@validator.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)
@validator.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?
@validator.validate
@validator.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/
@validator.validate
@validator.results.map(&:to_s).first.should.match /The URL (.*) is not reachable/
end
end
describe 'docset URL validation' do
before do
@sut.stubs(:validate_homepage)
@validator.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?
@validator.validate
@validator.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/
@validator.validate
@validator.results.map(&:to_s).first.should.match /The URL (.*) is not reachable/
end
end
end
it 'respects the no clean option' do
file = write_podspec(stub_podspec)
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.stubs(:validate_url)
sut.no_clean = true
sut.validate
sut.validation_dir.should.exist
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.stubs(:validate_url)
validator.no_clean = true
validator.validate
validator.validation_dir.should.exist
end
it 'builds the pod per platform' do
file = write_podspec(stub_podspec)
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.stubs(:validate_url)
sut.expects(:install_pod).twice
sut.expects(:build_pod).twice
sut.expects(:check_file_patterns).twice
sut.validate
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.stubs(:validate_url)
validator.expects(:install_pod).twice
validator.expects(:build_pod).twice
validator.expects(:check_file_patterns).twice
validator.validate
end
it 'uses the deployment target of the specification' do
sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.stubs(:validate_url)
sut.stubs(:validate_screenshots)
podfile = sut.send(:podfile_from_spec, :ios, '5.0')
validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
validator.stubs(:validate_url)
validator.stubs(:validate_screenshots)
podfile = validator.send(:podfile_from_spec, :ios, '5.0')
dependency = podfile.target_definitions['Pods'].dependencies.first
dependency.external_source.key?(:podspec).should.be.true
end
......@@ -303,12 +303,12 @@ module Pod
describe '#podfile_from_spec' do
before do
@sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
@sut.stubs(:validate_url)
@validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
@validator.stubs(:validate_url)
end
it 'configures the deployment target' do
podfile = @sut.send(:podfile_from_spec, :ios, '5.0')
podfile = @validator.send(:podfile_from_spec, :ios, '5.0')
target_definition = podfile.target_definitions['Pods']
platform = target_definition.platform
platform.symbolic_name.should == :ios
......@@ -316,13 +316,13 @@ module Pod
end
it 'includes the use_frameworks! directive' do
podfile = @sut.send(:podfile_from_spec, :ios, '5.0', true)
podfile = @validator.send(:podfile_from_spec, :ios, '5.0', true)
target_definition = podfile.target_definitions['Pods']
target_definition.uses_frameworks?.should == true
end
it 'includes the use_frameworks!(false) directive' do
podfile = @sut.send(:podfile_from_spec, :ios, '5.0', false)
podfile = @validator.send(:podfile_from_spec, :ios, '5.0', false)
target_definition = podfile.target_definitions['Pods']
(!!target_definition.uses_frameworks?).should == false
end
......@@ -330,74 +330,74 @@ module Pod
it 'repects the source_urls parameter' do
sources = %w(https://github.com/CocoaPods/Specs.git https://github.com/artsy/Specs.git)
sut = Validator.new(podspec_path, sources)
sut.stubs(:validate_url)
podfile = sut.send(:podfile_from_spec, :ios, '5.0')
validator = Validator.new(podspec_path, sources)
validator.stubs(:validate_url)
podfile = validator.send(:podfile_from_spec, :ios, '5.0')
podfile.sources.should == sources
end
it 'uses xcodebuild to generate notes and warnings' do
sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.stubs(:check_file_patterns)
sut.stubs(:xcodebuild).returns("file.m:1:1: warning: direct access to objective-c's isa is deprecated")
sut.stubs(:validate_url)
sut.validate
first = sut.results.map(&:to_s).first
validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
validator.stubs(:check_file_patterns)
validator.stubs(:xcodebuild).returns("file.m:1:1: warning: direct access to objective-c's isa is deprecated")
validator.stubs(:validate_url)
validator.validate
first = validator.results.map(&:to_s).first
first.should.include '[xcodebuild]'
sut.result_type.should == :note
validator.result_type.should == :note
end
it 'checks if xcodebuild returns a successful status code' do
Validator.any_instance.unstub(:xcodebuild)
sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.stubs(:check_file_patterns)
sut.stubs(:validate_url)
sut.stubs(:`).returns('Output')
validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
validator.stubs(:check_file_patterns)
validator.stubs(:validate_url)
validator.stubs(:`).returns('Output')
$?.stubs(:success?).returns(false)
sut.validate
first = sut.results.map(&:to_s).first
validator.validate
first = validator.results.map(&:to_s).first
first.should.include '[xcodebuild] Returned a unsuccessful exit code'
sut.result_type.should == :error
validator.result_type.should == :error
end
it 'does filter InputFile errors completely' do
sut = Validator.new(podspec_path, SourcesManager.master.map(&:url))
sut.stubs(:check_file_patterns)
sut.stubs(:xcodebuild).returns("2014-10-01 06:27:36.693 xcodebuild[61207:2007] error: InputFile Target Support Files/Pods-OneUpFoundation/Pods-OneUpFoundation-prefix.pch 0 1412159238 77 33188... malformed line 10; 'InputFile' should have exactly five arguments")
sut.stubs(:validate_url)
sut.validate
sut.results.count.should == 0
validator = Validator.new(podspec_path, SourcesManager.master.map(&:url))
validator.stubs(:check_file_patterns)
validator.stubs(:xcodebuild).returns("2014-10-01 06:27:36.693 xcodebuild[61207:2007] error: InputFile Target Support Files/Pods-OneUpFoundation/Pods-OneUpFoundation-prefix.pch 0 1412159238 77 33188... malformed line 10; 'InputFile' should have exactly five arguments")
validator.stubs(:validate_url)
validator.validate
validator.results.count.should == 0
end
describe 'file pattern validation' do
it 'checks for file patterns' do
file = write_podspec(stub_podspec(/.*source_files.*/, '"source_files": "wrong_paht.*",'))
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.stubs(:build_pod)
sut.stubs(:validate_url)
sut.validate
sut.results.map(&:to_s).first.should.match /source_files.*did not match/
sut.result_type.should == :error
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.stubs(:build_pod)
validator.stubs(:validate_url)
validator.validate
validator.results.map(&:to_s).first.should.match /source_files.*did not match/
validator.result_type.should == :error
end
it 'checks private_header_files matches only headers' do
file = write_podspec(stub_podspec(/.*source_files.*/, '"source_files": "JSONKit.*", "private_header_files": "JSONKit.m",'))
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.stubs(:build_pod)
sut.stubs(:validate_url)
sut.validate
sut.results.map(&:to_s).first.should.match /matches non-header files \(JSONKit\.m\)/
sut.result_type.should == :error
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.stubs(:build_pod)
validator.stubs(:validate_url)
validator.validate
validator.results.map(&:to_s).first.should.match /matches non-header files \(JSONKit\.m\)/
validator.result_type.should == :error
end
it 'checks public_header_files matches only headers' do
file = write_podspec(stub_podspec(/.*source_files.*/, '"source_files": "JSONKit.*", "public_header_files": "JSONKit.m",'))
sut = Validator.new(file, SourcesManager.master.map(&:url))
sut.stubs(:build_pod)
sut.stubs(:validate_url)
sut.validate
sut.results.map(&:to_s).first.should.match /matches non-header files \(JSONKit\.m\)/
sut.result_type.should == :error
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.stubs(:build_pod)
validator.stubs(:validate_url)
validator.validate
validator.results.map(&:to_s).first.should.match /matches non-header files \(JSONKit\.m\)/
validator.result_type.should == :error
end
end
......@@ -408,11 +408,11 @@ module Pod
file = write_podspec(podspec, 'ZKit.podspec.json')
spec = Specification.from_file(file)
sut = Validator.new(spec, SourcesManager.master.map(&:url))
sut.stubs(:validate_url)
sut.stubs(:build_pod)
sut.validate
sut.validated?.should.be.true
validator = Validator.new(spec, SourcesManager.master.map(&:url))
validator.stubs(:validate_url)
validator.stubs(:build_pod)
validator.validate
validator.validated?.should.be.true
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