<commit_before>$:.unshift(File.dirname(__FILE__), ".")
require 'spec_helper'
require 'cuke_salad/cli'

describe CukeSalad::CLI do
  let(:project) { 'Foobar' }
  let(:features) { project+'/features'}

  shared_examples_for "setup cuke_salad and cucumber" do
    it 'Can create features directory' do
      dir_exists?(features).should be_true
    end

    it 'can create features/support directory' do
      dir_exists?(features+'/support').should be_true
    end

    context 'in cuke_salad/features/support' do
      let(:file) { features+'/support/env.rb' }

      it 'can create a file env.rb' do
        File.exists?(file).should be_true
      end

      it 'with a given content' do
        content = "require 'cuke_salad'\n begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end"
        IO.read(file).should == content
      end
    end

    it 'can create lib directory' do
      dir_exists?(features+'/lib').should be_true
    end

    it 'can create lib/default directory' do
      dir_exists?(features+'/lib/default').should be_true
    end

    it 'can create features/lib/roles directory' do
      dir_exists?(features+'/lib/default/roles').should be_true
    end

    it 'can create tasks directory' do
      dir_exists?(features+'/lib/default/tasks').should be_true
    end
  end


  context 'Create new project Foobar' do

    before(:all) do
      cli = CukeSalad::CLI.create_new_project(project)
    end

    it "Can create the project directory" do
      dir_exists?(project).should be_true
    end

    it_should_behave_like "setup cuke_salad and cucumber"
  end

  context 'Setup existing project' do
    before(:all) do
      `cd Foobar`
      CukeSalad::CLI.configure_existing_project
    end
    it_should_behave_like "setup cuke_salad and cucumber"
  end


  def dir_exists? file
    File.exists?(file)
  end

  after(:all) do
    FileUtils.rm_rf project
  end
end<commit_msg>tests created in tmp/aruba  renaming spec descriptions<commit_after>$:.unshift(File.dirname(__FILE__), ".")
require 'spec_helper'
require 'cuke_salad/cli'

# don't override aruba path
module CukeSalad
  class CLI
    class Structure
      def initialize
      end
    end
  end
end

def dir_exists? file
  File.exists?("tmp/aruba/"+file)
end

def file_content file
  IO.read("tmp/aruba/"+file)
end

alias :file_exists? :dir_exists?

describe CukeSalad::CLI do

  shared_examples_for "setup cuke_salad and cucumber" do
    it 'creates features directory' do
      dir_exists?(features).should be_true
    end

    context 'in features' do
      it 'creates support directory' do
        dir_exists?(features+'/support').should be_true
      end

      context 'in support' do
        let(:file) { features+'/support/env.rb' }

        it 'creates a file env.rb' do
          file_exists?(file).should be_true
        end

        it 'env.rb has the right content' do
          content = "require 'cuke_salad'\n begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end"
          file_content(file).should == content
        end
      end

      it 'creates lib directory' do
        dir_exists?(features+'/lib').should be_true
      end

      context 'in lib' do
        it 'creates default directory' do
          dir_exists?(features+'/lib/default').should be_true
        end

        context 'in features/lib/default' do
          it 'creates roles directory' do
            dir_exists?(features+'/lib/default/roles').should be_true
          end

          it 'creates tasks directory' do
            dir_exists?(features+'/lib/default/tasks').should be_true
          end
        end
      end
    end
  end

  context 'Create new project foobar' do
    let(:new_project) { 'foobar' }
    let(:features) { new_project + "/features" }

    before(:all) do
      CukeSalad::CLI.create_new_project(new_project)
    end

    it "creates the project directory" do
      dir_exists?(new_project).should be_true
    end

    it_should_behave_like "setup cuke_salad and cucumber"
  end

  context 'Setup existing project' do
    let(:features) { 'features' }

    before(:all) do
      CukeSalad::CLI.configure_existing_project
    end
    it_should_behave_like "setup cuke_salad and cucumber"
  end

  after(:all) do
    FileUtils.rm_rf 'tmp'
  end
end
{'fraction_non_alphanumeric': 0.09480760315252666, 'fraction_numerical': 0.0, 'mean_word_length': 2.842386464826358, 'pattern_counts': {'":': 0, '<': 3, '<?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': '896153', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1348, 'n_words': 367}