Commit cb2942f8 authored by Fabio Pelosin's avatar Fabio Pelosin

[Specs] Adapting existing specs for recent changes.

parent 2426f95c
...@@ -125,17 +125,23 @@ describe "Pod::Command::Spec#lint" do ...@@ -125,17 +125,23 @@ describe "Pod::Command::Spec#lint" do
end end
end end
before do
text = (fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec').read
text.gsub!(/.*license.*/, "")
file = temporary_directory + 'JSONKit.podspec'
File.open(file, 'w') {|f| f.write(text) }
@spec_path = file.to_s
end
it "lints a givent podspec" do it "lints a givent podspec" do
spec_file = fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec' cmd = command('spec', 'lint', '--quick', @spec_path)
cmd = command('spec', 'lint', '--quick', spec_file.to_s)
lambda { cmd.run }.should.raise Pod::Informative lambda { cmd.run }.should.raise Pod::Informative
cmd.output.should.include "Missing license file or text" cmd.output.should.include "Missing license type"
end end
it "respects the -only--errors option" do it "respects the -only--errors option" do
spec_file = fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec' cmd = command('spec', 'lint', '--quick', '--only-errors', @spec_path)
cmd = command('spec', 'lint', '--quick', '--only-errors', spec_file.to_s)
lambda { cmd.run }.should.not.raise lambda { cmd.run }.should.not.raise
cmd.output.should.include "Missing license file or text" cmd.output.should.include "Missing license type"
end end
end end
...@@ -155,7 +155,7 @@ else ...@@ -155,7 +155,7 @@ else
end end
end end
Pod::Specification.any_instance.stubs(:clean_paths).returns(['JSONKit/CHANGELOG.md']) Pod::Specification.any_instance.stubs(:preserve_paths).returns(['CHANGELOG.md'])
installer = SpecHelper::Installer.new(podfile) installer = SpecHelper::Installer.new(podfile)
installer.install! installer.install!
......
...@@ -53,7 +53,7 @@ describe "Pod::Command::Spec::Linter" do ...@@ -53,7 +53,7 @@ describe "Pod::Command::Spec::Linter" do
end end
it "fails validation if the specification contains warnings" do it "fails validation if the specification contains warnings" do
spec, file = write_podspec(stub_podspec) spec, file = write_podspec(stub_podspec(/.*license.*/, ""))
linter = Pod::Command::Spec::Linter.new(spec) linter = Pod::Command::Spec::Linter.new(spec)
linter.lenient, linter.quick = false, true linter.lenient, linter.quick = false, true
linter.lint.should == false linter.lint.should == false
...@@ -62,7 +62,7 @@ describe "Pod::Command::Spec::Linter" do ...@@ -62,7 +62,7 @@ describe "Pod::Command::Spec::Linter" do
end end
it "validates in lenient mode if there are no erros but there are warnings" do it "validates in lenient mode if there are no erros but there are warnings" do
spec, file = write_podspec(stub_podspec) spec, file = write_podspec(stub_podspec(/.*license.*/, ""))
linter = Pod::Command::Spec::Linter.new(spec) linter = Pod::Command::Spec::Linter.new(spec)
linter.lenient, linter.quick = true, true linter.lenient, linter.quick = true, true
linter.lint.should == true linter.lint.should == true
...@@ -87,7 +87,7 @@ describe "Pod::Command::Spec::Linter" do ...@@ -87,7 +87,7 @@ describe "Pod::Command::Spec::Linter" do
linter.lenient, linter.quick = false, true linter.lenient, linter.quick = false, true
linter.lint.should == false linter.lint.should == false
linter.errors.should.be.empty linter.errors.should.be.empty
linter.warnings.join(' | ').should =~ /`config.ios\?' and `config.osx\?' are deprecated and will be removed in version 0.7/ linter.warnings.join(' | ').should =~ /`config.ios\?' and `config.osx\?' are deprecated/
end end
it "uses xcodebuild to generate notes and warnings" do it "uses xcodebuild to generate notes and warnings" do
...@@ -104,6 +104,6 @@ describe "Pod::Command::Spec::Linter" do ...@@ -104,6 +104,6 @@ describe "Pod::Command::Spec::Linter" do
linter.stubs(:xcodebuild_output).returns([]) linter.stubs(:xcodebuild_output).returns([])
linter.lenient, linter.quick = false, false linter.lenient, linter.quick = false, false
linter.lint.should == false linter.lint.should == false
linter.errors.join(' | ').should.include "[resources = 'WRONG_FOLDER'] -> did not match any file" linter.errors.join(' | ').should.include "The resources did not match any file"
end end
end end
...@@ -19,10 +19,7 @@ describe Pod::Generator::Documentation do ...@@ -19,10 +19,7 @@ describe Pod::Generator::Documentation do
end end
it 'returns the Pod documentation documentation files' do it 'returns the Pod documentation documentation files' do
@doc_installer.files.sort.should == [ @doc_installer.files.sort.should == %w[ Classes/Banana.m Classes/Banana.h ].sort
(@pod.root + "Classes/Banana.m").to_s,
(@pod.root + "Classes/Banana.h").to_s,
].sort
end end
it 'returns the Pod documentation options' do it 'returns the Pod documentation options' do
......
...@@ -3,174 +3,191 @@ require File.expand_path('../../spec_helper', __FILE__) ...@@ -3,174 +3,191 @@ require File.expand_path('../../spec_helper', __FILE__)
describe Pod::LocalPod do describe Pod::LocalPod do
# a LocalPod represents a local copy of the dependency, inside the pod root, built from a spec # a LocalPod represents a local copy of the dependency, inside the pod root, built from a spec
describe "in general" do
before do
@sandbox = temporary_sandbox
@pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), @sandbox, Pod::Platform.new(:ios))
copy_fixture_to_pod('banana-lib', @pod)
end
before do it 'returns the Pod root directory path' do
@sandbox = temporary_sandbox @pod.root.should == @sandbox.root + 'BananaLib'
@pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), @sandbox, Pod::Platform.new(:ios)) end
copy_fixture_to_pod('banana-lib', @pod)
end
it 'returns the Pod root directory path' do
@pod.root.should == @sandbox.root + 'BananaLib'
end
it "creates it's own root directory if it doesn't exist" do it "creates it's own root directory if it doesn't exist" do
@pod.create @pod.create
File.directory?(@pod.root).should.be.true File.directory?(@pod.root).should.be.true
end end
it "can execute a block within the context of it's root" do it "can execute a block within the context of it's root" do
@pod.chdir { FileUtils.touch("foo") } @pod.chdir { FileUtils.touch("foo") }
Pathname(@pod.root + "foo").should.exist Pathname(@pod.root + "foo").should.exist
end end
it 'can delete itself' do it 'can delete itself' do
@pod.create @pod.create
@pod.implode @pod.implode
@pod.root.should.not.exist @pod.root.should.not.exist
end end
it 'returns an expanded list of source files, relative to the sandbox root' do it 'returns an expanded list of source files, relative to the sandbox root' do
@pod.source_files.sort.should == [ @pod.source_files.sort.should == [
Pathname.new("BananaLib/Classes/Banana.m"), Pathname.new("BananaLib/Classes/Banana.m"),
Pathname.new("BananaLib/Classes/Banana.h") Pathname.new("BananaLib/Classes/Banana.h")
].sort ].sort
end end
xit 'returns an expanded list of absolute clean paths' do it 'returns an expanded list of absolute clean paths' do
@pod.clean_paths.should == [@sandbox.root + "BananaLib/sub-dir"] #TODO: there are some temporary files that prevent a complete check
end @pod.clean_paths.map { |p| p.relative_path_from(@sandbox.root).to_s }.should.include 'BananaLib/sub-dir/sub-dir-2/somefile.txt'
end
it 'returns an expanded list of resources, relative to the sandbox root' do it 'returns an expanded list of resources, relative to the sandbox root' do
@pod.resources.should == [Pathname.new("BananaLib/Resources/logo-sidebar.png")] @pod.resources.should == [Pathname.new("BananaLib/Resources/logo-sidebar.png")]
end end
it 'returns a list of header files' do it 'returns a list of header files' do
@pod.header_files.should == [Pathname.new("BananaLib/Classes/Banana.h")] @pod.header_files.should == [Pathname.new("BananaLib/Classes/Banana.h")]
end end
xit 'can clean up after itself' do xit 'can clean up after itself' do
@pod.clean_paths.tap do |paths|
@pod.clean @pod.clean
@pod.clean_paths.tap do |paths|
paths.each do |path| paths.each do |path|
path.should.not.exist path.should.not.exist
end
end end
end end
end
it "can link it's headers into the sandbox" do it "can link it's headers into the sandbox" do
@pod.link_headers @pod.link_headers
expected_header_path = @sandbox.headers_root + "BananaLib/Banana.h" expected_header_path = @sandbox.headers_root + "BananaLib/Banana.h"
expected_header_path.should.be.symlink expected_header_path.should.be.symlink
File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read File.read(expected_header_path).should == (@sandbox.root + @pod.header_files[0]).read
end end
it "can add it's source files to an Xcode project target" do it "can add it's source files to an Xcode project target" do
target = mock('target') target = mock('target')
target.expects(:add_source_file).with(Pathname.new("BananaLib/Classes/Banana.m"), anything, anything) target.expects(:add_source_file).with(Pathname.new("BananaLib/Classes/Banana.h"), anything, anything)
@pod.add_to_target(target) target.expects(:add_source_file).with(Pathname.new("BananaLib/Classes/Banana.m"), anything, anything)
end @pod.add_to_target(target)
end
it "can add it's source files to a target with any specially configured compiler flags" do it "can add it's source files to a target with any specially configured compiler flags" do
@pod.top_specification.compiler_flags = '-d some_flag' @pod.top_specification.compiler_flags = '-d some_flag'
target = mock('target') target = mock('target')
target.expects(:add_source_file).with(anything, anything, "-d some_flag") target.expects(:add_source_file).twice.with(anything, anything, "-d some_flag")
@pod.add_to_target(target) @pod.add_to_target(target)
end
end end
end
describe "A Pod::LocalPod, with installed source," do describe "with installed source," do
#before do #before do
#config.project_pods_root = fixture('integration') #config.project_pods_root = fixture('integration')
#podspec = fixture('spec-repos/master/SSZipArchive/0.1.0/SSZipArchive.podspec') #podspec = fixture('spec-repos/master/SSZipArchive/0.1.0/SSZipArchive.podspec')
#@spec = Pod::Specification.from_file(podspec) #@spec = Pod::Specification.from_file(podspec)
#@destroot = fixture('integration/SSZipArchive') #@destroot = fixture('integration/SSZipArchive')
#end #end
#after do #after do
#config.project_pods_root = nil #config.project_pods_root = nil
#end #end
xit "returns the list of files that the source_files pattern expand to" do xit "returns the list of files that the source_files pattern expand to" do
files = @destroot.glob('**/*.{h,c,m}') files = @destroot.glob('**/*.{h,c,m}')
files = files.map { |file| file.relative_path_from(config.project_pods_root) } files = files.map { |file| file.relative_path_from(config.project_pods_root) }
@spec.expanded_source_files[:ios].sort.should == files.sort @spec.expanded_source_files[:ios].sort.should == files.sort
end end
xit "returns the list of headers" do xit "returns the list of headers" do
files = @destroot.glob('**/*.h') files = @destroot.glob('**/*.h')
files = files.map { |file| file.relative_path_from(config.project_pods_root) } files = files.map { |file| file.relative_path_from(config.project_pods_root) }
@spec.header_files[:ios].sort.should == files.sort @spec.header_files[:ios].sort.should == files.sort
end end
xit "returns a hash of mappings from the pod's destroot to its header dirs, which by default is just the pod's header dir" do xit "returns a hash of mappings from the pod's destroot to its header dirs, which by default is just the pod's header dir" do
@spec.copy_header_mappings[:ios].size.should == 1 @spec.copy_header_mappings[:ios].size.should == 1
@spec.copy_header_mappings[:ios][Pathname.new('SSZipArchive')].sort.should == %w{ @spec.copy_header_mappings[:ios][Pathname.new('SSZipArchive')].sort.should == %w{
SSZipArchive.h SSZipArchive.h
minizip/crypt.h minizip/crypt.h
minizip/ioapi.h minizip/ioapi.h
minizip/mztools.h minizip/mztools.h
minizip/unzip.h minizip/unzip.h
minizip/zip.h minizip/zip.h
}.map { |f| Pathname.new("SSZipArchive/#{f}") }.sort }.map { |f| Pathname.new("SSZipArchive/#{f}") }.sort
end
xit "allows for customization of header mappings by overriding copy_header_mapping" do
def @spec.copy_header_mapping(from)
Pathname.new('ns') + from.basename
end end
@spec.copy_header_mappings[:ios].size.should == 1
@spec.copy_header_mappings[:ios][Pathname.new('SSZipArchive/ns')].sort.should == %w{ xit "allows for customization of header mappings by overriding copy_header_mapping" do
def @spec.copy_header_mapping(from)
Pathname.new('ns') + from.basename
end
@spec.copy_header_mappings[:ios].size.should == 1
@spec.copy_header_mappings[:ios][Pathname.new('SSZipArchive/ns')].sort.should == %w{
SSZipArchive.h SSZipArchive.h
minizip/crypt.h minizip/crypt.h
minizip/ioapi.h minizip/ioapi.h
minizip/mztools.h minizip/mztools.h
minizip/unzip.h minizip/unzip.h
minizip/zip.h minizip/zip.h
}.map { |f| Pathname.new("SSZipArchive/#{f}") }.sort }.map { |f| Pathname.new("SSZipArchive/#{f}") }.sort
end end
xit "returns a hash of mappings with a custom header dir prefix" do xit "returns a hash of mappings with a custom header dir prefix" do
@spec.header_dir = 'AnotherRoot' @spec.header_dir = 'AnotherRoot'
@spec.copy_header_mappings[:ios][Pathname.new('AnotherRoot')].sort.should == %w{ @spec.copy_header_mappings[:ios][Pathname.new('AnotherRoot')].sort.should == %w{
SSZipArchive.h SSZipArchive.h
minizip/crypt.h minizip/crypt.h
minizip/ioapi.h minizip/ioapi.h
minizip/mztools.h minizip/mztools.h
minizip/unzip.h minizip/unzip.h
minizip/zip.h minizip/zip.h
}.map { |f| Pathname.new("SSZipArchive/#{f}") }.sort }.map { |f| Pathname.new("SSZipArchive/#{f}") }.sort
end
xit "returns the user header search paths" do
def @spec.copy_header_mapping(from)
Pathname.new('ns') + from.basename
end end
@spec.header_search_paths.should == %w{
xit "returns the user header search paths" do
def @spec.copy_header_mapping(from)
Pathname.new('ns') + from.basename
end
@spec.header_search_paths.should == %w{
"$(PODS_ROOT)/Headers/SSZipArchive" "$(PODS_ROOT)/Headers/SSZipArchive"
"$(PODS_ROOT)/Headers/SSZipArchive/ns" "$(PODS_ROOT)/Headers/SSZipArchive/ns"
} }
end
xit "returns the user header search paths with a custom header dir prefix" do
@spec.header_dir = 'AnotherRoot'
def @spec.copy_header_mapping(from)
Pathname.new('ns') + from.basename
end end
@spec.header_search_paths.should == %w{
xit "returns the user header search paths with a custom header dir prefix" do
@spec.header_dir = 'AnotherRoot'
def @spec.copy_header_mapping(from)
Pathname.new('ns') + from.basename
end
@spec.header_search_paths.should == %w{
"$(PODS_ROOT)/Headers/AnotherRoot" "$(PODS_ROOT)/Headers/AnotherRoot"
"$(PODS_ROOT)/Headers/AnotherRoot/ns" "$(PODS_ROOT)/Headers/AnotherRoot/ns"
} }
end
xit "returns the list of files that the resources pattern expand to" do
@spec.expanded_resources.should == {}
@spec.resource = 'LICEN*'
@spec.expanded_resources[:ios].map(&:to_s).should == %w{ SSZipArchive/LICENSE }
@spec.expanded_resources[:osx].map(&:to_s).should == %w{ SSZipArchive/LICENSE }
@spec.resources = 'LICEN*', 'Readme.*'
@spec.expanded_resources[:ios].map(&:to_s).should == %w{ SSZipArchive/LICENSE SSZipArchive/Readme.markdown }
@spec.expanded_resources[:osx].map(&:to_s).should == %w{ SSZipArchive/LICENSE SSZipArchive/Readme.markdown }
end
end end
xit "returns the list of files that the resources pattern expand to" do describe "with installed source from multiple subspecs" do
@spec.expanded_resources.should == {} xit "returns the source files of the activated specs"
@spec.resource = 'LICEN*'
@spec.expanded_resources[:ios].map(&:to_s).should == %w{ SSZipArchive/LICENSE } xit "returns the resources of the activated specs"
@spec.expanded_resources[:osx].map(&:to_s).should == %w{ SSZipArchive/LICENSE }
@spec.resources = 'LICEN*', 'Readme.*' xit "can provide the source files of all the subspecs" do
@spec.expanded_resources[:ios].map(&:to_s).should == %w{ SSZipArchive/LICENSE SSZipArchive/Readme.markdown } pod.all_specs_source_files.should == %w[]
@spec.expanded_resources[:osx].map(&:to_s).should == %w{ SSZipArchive/LICENSE SSZipArchive/Readme.markdown } end
xit "can provide the source files of all the subspecs" do
sources = @pod.all_specs_source_files.map { |p| p.relative_path_from(@sandbox.root).to_s }
sources.should == %w[ BananaLib/Classes/Banana.h BananaLib/Classes/Banana.m ]
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