<commit_before>require 'spec_helper'

describe Travis::CLI::Init do
  before(:each) do
    FileUtils.mkdir_p "spec/tmp"
    Dir.chdir "spec/tmp"
    FileUtils.rm('.travis.yml') if File.exist?('.travis.yml')
  end

  after(:each) do
    Dir.chdir ".."
    FileUtils.rm('spec/tmp/.travis.yml') if File.exist?('spec/tmp/.travis.yml')
  end

  example "travis init fakelanguage" do
    run_cli('init', 'fakelanguage').should_not be_success
    stderr.should be == "unknown language fakelanguage\n"
  end

  shared_examples_for 'travis init' do |language|
    example "travis init #{language} (empty directory)" do
      File.exist?('.travis.yml').should be_false
      run_cli('init', language).should be_success
      stdout.should be == ".travis.yml file created!\n"
      File.exist?('.travis.yml').should be_true
      File.read('.travis.yml').should start_with("language: #{language}")
    end

    example "travis init #{language} (.travis.yml already exists, using --force)" do
      File.open(".travis.yml", "w") { |f| f << "old file" }
      run_cli('init', language, '--force').should be_success
      stdout.should be == ".travis.yml file created!\n"
      File.read(".travis.yml").should_not be == "old file"
    end

    example "travis init #{language} (.travis.yml already exists, not using --force)" do
      File.open(".travis.yml", "w") { |f| f << "old file" }
      run_cli('init', 'ruby').should_not be_success
      stderr.should be == ".travis.yml already exists, use --force to override\n"
      File.read('.travis.yml').should be == "old file"
    end
  end

  describe 'travis init ruby' do
    it_should_behave_like 'travis init', 'ruby'
  end
end<commit_msg>1.8 does not respect order<commit_after>require 'spec_helper'

describe Travis::CLI::Init do
  before(:each) do
    FileUtils.mkdir_p "spec/tmp"
    Dir.chdir "spec/tmp"
    FileUtils.rm('.travis.yml') if File.exist?('.travis.yml')
  end

  after(:each) do
    Dir.chdir ".."
    FileUtils.rm('spec/tmp/.travis.yml') if File.exist?('spec/tmp/.travis.yml')
  end

  example "travis init fakelanguage" do
    run_cli('init', 'fakelanguage').should_not be_success
    stderr.should be == "unknown language fakelanguage\n"
  end

  shared_examples_for 'travis init' do |language|
    example "travis init #{language} (empty directory)" do
      File.exist?('.travis.yml').should be_false
      run_cli('init', language).should be_success
      stdout.should be == ".travis.yml file created!\n"
      File.exist?('.travis.yml').should be_true
      File.read('.travis.yml').should include("language: #{language}")
    end

    example "travis init #{language} (.travis.yml already exists, using --force)" do
      File.open(".travis.yml", "w") { |f| f << "old file" }
      run_cli('init', language, '--force').should be_success
      stdout.should be == ".travis.yml file created!\n"
      File.read(".travis.yml").should_not be == "old file"
    end

    example "travis init #{language} (.travis.yml already exists, not using --force)" do
      File.open(".travis.yml", "w") { |f| f << "old file" }
      run_cli('init', 'ruby').should_not be_success
      stderr.should be == ".travis.yml already exists, use --force to override\n"
      File.read('.travis.yml').should be == "old file"
    end
  end

  describe 'travis init ruby' do
    it_should_behave_like 'travis init', 'ruby'
  end
end
{'fraction_non_alphanumeric': 0.1592526690391459, 'fraction_numerical': 0.0005931198102016608, 'mean_word_length': 3.269620253164557, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '197579', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1158, 'n_words': 283}