lib/sass_spec/test.rb
# Creates a copy of the test test that's compatible with the current version.
#
# Marks the original as only being valid until the version before the current
# version. Marks the copy as being valid starting with the current version.
# Updates the copy to expect current actual results.
Creates a copy of the test test that's compatible with the current version.
Marks the original as only being valid until the version before the current
version. Marks the copy as being valid starting with the current version.
Updates the copy to expect current actual results.
Creates a copy of the test test that ' s compatible with the current version . Marks the original as only being valid until the version before the current version . Marks the copy as being valid starting with the current version . Updates the copy to expect current actual results .
def migrate_version!
    current_version = @options[:language_version]
    current_version_index = SassSpec::LANGUAGE_VERSIONS.index(current_version)
    if current_version_index == 0
      puts "Cannot migrate test. There's no version earlier than #{current_version}."
      return
    end
    start_version_index = SassSpec::LANGUAGE_VERSIONS.index(
      @test_case.metadata.start_version.to_s)
    if start_version_index >= current_version_index
      puts "Cannot migrate test. Test does not apply to an earlier version."
      return
    end
    previous_version = SassSpec::LANGUAGE_VERSIONS[current_version_index - 1]
    new_folder = @test_case.folder + "-#{current_version}"
    if File.exist?(new_folder)
      choice = interact(:migrate_over_existing, :abort) do |i|
        i.prompt("Target folder '#{new_folder}' already exists.")
        i.choice('x', "Don't migrate the test.") do
          return
        end
        i.choice('O', "Remove it.") do
          unless delete_dir!(new_folder)
            i.restart!
          end
        end
      end
      if choice == :abort
        puts "Cannot migrate test. #{new_folder} already exists."
        return
      end
    end
    FileUtils.cp_r @test_case.folder, new_folder
    new_test_case = SassSpec::TestCase.new(new_folder, @options[:engine_adapter].describe)
    change_options(end_version: previous_version)
    change_options(new_test_case.options_path, start_version: current_version)
    overwrite_test!(new_test_case)
  end
def migrate_version! current_version = @options [ :language_version ] current_version_index = SassSpec :: LANGUAGE_VERSIONS . index ( current_version ) if current_version_index == 0 puts "Cannot migrate test. There's no version earlier than #{current_version}." return end start_version_index = SassSpec :: LANGUAGE_VERSIONS . index ( @test_case . metadata . start_version . to_s ) if start_version_index >= current_version_index puts "Cannot migrate test. Test does not apply to an earlier version." return end previous_version = SassSpec :: LANGUAGE_VERSIONS [ current_version_index - 1 ] new_folder = @test_case . folder + "-#{current_version}" if File . exist? ( new_folder ) choice = interact ( :migrate_over_existing , :abort ) do | i | i . prompt ( "Target folder '#{new_folder}' already exists." ) i . choice ( 'x' , "Don't migrate the test." ) do return end i . choice ( 'O' , "Remove it." ) do unless delete_dir! ( new_folder ) i . restart! end end end if choice == :abort puts "Cannot migrate test. #{new_folder} already exists." return end end FileUtils . cp_r @test_case . folder , new_folder new_test_case = SassSpec :: TestCase . new ( new_folder , @options [ :engine_adapter ] . describe ) change_options ( end_version : previous_version ) change_options ( new_test_case . options_path , start_version : current_version ) overwrite_test! ( new_test_case ) end
Creates a copy of the test test that's compatible with the current version.
Creates a copy of the test test that ' s compatible with the current version .