Commit ac38ef86 authored by Samuel Giddins's avatar Samuel Giddins

[Installer] Add specs for deintegrating on major version changes

parent f4f8e112
......@@ -494,8 +494,8 @@ module Pod
# @return [void]
#
def deintegrate_if_different_major_version
return unless config.lockfile
return if config.lockfile.cocoapods_version.major == Version.new(VERSION).major
return unless lockfile
return if lockfile.cocoapods_version.major == Version.create(VERSION).major
UI.section('Fully deintegrating due to major version update') do
projects = Pathname.glob(config.installation_root + '*.xcodeproj').map { |path| Xcodeproj::Project.open(path) }
deintegrator = Deintegrator.new
......
......@@ -4,12 +4,12 @@ require 'cocoapods_stats/sender'
# @return [Lockfile]
#
def generate_lockfile
def generate_lockfile(lockfile_version: Pod::VERSION)
hash = {}
hash['PODS'] = []
hash['DEPENDENCIES'] = []
hash['SPEC CHECKSUMS'] = []
hash['COCOAPODS'] = Pod::VERSION
hash['COCOAPODS'] = lockfile_version
Pod::Lockfile.new(hash)
end
......@@ -177,6 +177,38 @@ module Pod
end.message.should.match /should.*run.*outside.*Pods directory.*Current directory.*\./m
end
end
describe 'handling CocoaPods version updates' do
it 'does not deintegrate when there is no lockfile' do
installer = Pod::Installer.new(config.sandbox, generate_podfile, nil)
UI.expects(:section).never
installer.send(:deintegrate_if_different_major_version)
end
it 'does not deintegrate when the major version is the same' do
VERSION.stubs(:to_s).returns('1.1.0')
should_not_deintegrate = %w(1.0.0 1.0.1 1.1.0 1.2.2)
should_not_deintegrate.each do |version|
lockfile = generate_lockfile(:lockfile_version => version)
installer = Pod::Installer.new(config.sandbox, generate_podfile, lockfile)
Pathname.expects(:glob).never
installer.send(:deintegrate_if_different_major_version)
end
end
it 'does deintegrate when the major version is the same' do
VERSION.stubs(:to_s).returns('1.1.0')
should_not_deintegrate = %w(0.39.0 2.0.0 10.0-beta)
should_not_deintegrate.each do |version|
lockfile = generate_lockfile(:lockfile_version => version)
installer = Pod::Installer.new(config.sandbox, generate_podfile, lockfile)
project = fixture('SampleProject/SampleProject.xcodeproj')
Pathname.expects(:glob).with(config.installation_root + '*.xcodeproj').returns([project])
Deintegrator.any_instance.expects(:deintegrate_project)
installer.send(:deintegrate_if_different_major_version)
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