Commit 81ee36aa authored by Boris Bügling's avatar Boris Bügling

Stub `pathname` in relevant places.

parent 672e2804
......@@ -252,24 +252,30 @@ module Pod
pod 'monkey', :path => (fixture_path + 'monkey').to_s
end
@lockfile = generate_lockfile
@file = Pathname('/yolo.m')
@file.stubs(:realpath).returns(@file)
@libThing = Pathname('/libThing.a')
@libThing.stubs(:realpath).returns(@libThing)
end
it 'detects transitive static dependencies which are linked directly to the user target' do
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([Pathname('/libThing.a')])
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@libThing])
@installer = Installer.new(config.sandbox, @podfile, @lockfile)
should.raise(Informative) { @installer.install! }.message.should.match /transitive.*libThing/
end
it 'allows transitive static dependencies which contain other source code' do
Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([Pathname('/yolo.m')])
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([Pathname('/libThing.a')])
Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([@file])
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@libThing])
@installer = Installer.new(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @installer.install! }
end
it 'allows transitive static dependencies when both dependencies are linked against the user target' do
PodTarget.any_instance.stubs(:should_build? => false)
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([Pathname('/libThing.a')])
Sandbox::FileAccessor.any_instance.stubs(:vendored_libraries).returns([@libThing])
@installer = Installer.new(config.sandbox, @podfile, @lockfile)
should.not.raise(Informative) { @installer.install! }
end
......
......@@ -174,26 +174,31 @@ module Pod
end
it 'adds a file references to the given file' do
Pathname.any_instance.stubs(:realpath).returns(@file)
ref = @project.add_file_reference(@file, @group)
ref.hierarchy_path.should == '/Pods/BananaLib/file.m'
end
it 'adds subgroups for a file reference if requested' do
Pathname.any_instance.stubs(:realpath).returns(@nested_file)
ref = @project.add_file_reference(@nested_file, @group, true)
ref.hierarchy_path.should == '/Pods/BananaLib/Dir/SubDir/nested_file.m'
end
it 'does not add subgroups for a file reference if not requested' do
Pathname.any_instance.stubs(:realpath).returns(@nested_file)
ref = @project.add_file_reference(@nested_file, @group)
ref.hierarchy_path.should == '/Pods/BananaLib/nested_file.m'
end
it 'does not add subgroups for a file reference if requested not to' do
Pathname.any_instance.stubs(:realpath).returns(@nested_file)
ref = @project.add_file_reference(@nested_file, @group, false)
ref.hierarchy_path.should == '/Pods/BananaLib/nested_file.m'
end
it "it doesn't duplicate file references for a single path" do
Pathname.any_instance.stubs(:realpath).returns(@file)
ref_1 = @project.add_file_reference(@file, @group)
ref_2 = @project.add_file_reference(@file, @group)
ref_1.uuid.should == ref_2.uuid
......@@ -201,12 +206,14 @@ module Pod
end
it 'creates variant group for localized file' do
Pathname.any_instance.stubs(:realpath).returns(@localized_file)
ref = @project.add_file_reference(@localized_file, @group)
ref.hierarchy_path.should == '/Pods/BananaLib/Foo/Foo.strings'
ref.parent.class.should == Xcodeproj::Project::Object::PBXVariantGroup
end
it 'creates variant group for localized file in subgroup' do
Pathname.any_instance.stubs(:realpath).returns(@localized_file)
ref = @project.add_file_reference(@localized_file, @group, true)
ref.hierarchy_path.should == '/Pods/BananaLib/Dir/SubDir/Foo/Foo.strings'
ref.parent.class.should == Xcodeproj::Project::Object::PBXVariantGroup
......@@ -312,6 +319,7 @@ module Pod
@project.add_pod_group('BananaLib', config.sandbox.pod_dir('BananaLib'), false)
@file = config.sandbox.pod_dir('BananaLib') + 'file.m'
@group = @project.group_for_spec('BananaLib')
Pathname.any_instance.stubs(:realpath).returns(@file)
@project.add_file_reference(@file, @group)
end
......
......@@ -729,9 +729,11 @@ module Pod
def test_swiftpod
podspec = stub_podspec(/.*source_files.*/, '"source_files": "*.swift",')
file = write_podspec(podspec)
pathname = Pathname.new('/Foo.swift')
pathname.stubs(:realpath).returns(pathname)
Podfile::TargetDefinition.any_instance.stubs(:uses_frameworks?).returns(true)
Pod::Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([Pathname.new('/Foo.swift')])
Pod::Sandbox::FileAccessor.any_instance.stubs(:source_files).returns([pathname])
validator = Validator.new(file, SourcesManager.master.map(&:url))
validator.stubs(:build_pod)
validator.stubs(:validate_url)
......
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