<commit_before>require "spec_helper"
require "pdqtest/skeleton"
require "fileutils"
require 'fakefs/safe'

describe PDQTest::Skeleton do

  before do
    # copy in the whole project folder to a location identical to the current directory
    # so that the skeleton files can be loaded, since fakefs prevents access to
    # the real ones
    pwd = Dir.pwd
    config = File.expand_path('.')
    FakeFS::FileSystem.clone(config, pwd)
  end

  it "removes fixtures.yml" do
    config = File.expand_path('./spec/fixtures/blank_module')
    FakeFS::FileSystem.clone(config, '/apache')

    FakeFS do
      Dir.chdir('/apache') do
        FileUtils.touch '.fixtures.yml'

        PDQTest::Skeleton.init
        # ..to be_an_existing_file doesn't work with fakefs...
        expect(File.exists?('.fixtures.yml')).to be false
        expect(File.exists?('.fixtures.yml.pdqtest_old')).to be true
      end
    end
  end

  it "creates testcase directory structure correctly" do
    config = File.expand_path('./spec/fixtures/blank_module')
    FakeFS::FileSystem.clone(config, '/apache')

    FakeFS do
      Dir.chdir('/apache') do
        PDQTest::Skeleton.init

        expect(Dir.exists?('./spec')).to be true
        expect(Dir.exists?('./spec/acceptance')).to be true
        expect(Dir.exists?('./spec/classes')).to be true
        expect(Dir.exists?('./examples')).to be true
      end
    end
  end

  it "creates skeleton files if required" do
    config = File.expand_path('./spec/fixtures/blank_module')
    FakeFS::FileSystem.clone(config, '/apache')

    FakeFS do
    puts File.read('/Users/geoff/github/pdqtest/lib/pdqtest/../../res/skeleton/Rakefile')
      Dir.chdir('/apache') do
        PDQTest::Skeleton.init
        expect(File.exists?('Rakefile')).to be true
        expect(File.exists?(File.join('spec', 'spec_helper.rb'))).to be true
        expect(File.exists?('Rakefile.pdqtest_old')).to be true
        expect(File.exists?(File.join('spec', 'spec_helper.rb.pdqtest_old'))).to be true
        expect(File.exists?(File.join('spec', 'acceptance', 'init__setup.sh'))).to be true
        expect(File.exists?(File.join('spec', 'acceptance', 'init__before.bats'))).to be true
        expect(File.exists?(File.join('spec', 'acceptance', 'init.bats'))).to be true
        expect(File.exists?(File.join('examples', 'init.pp'))).to be true
        expect(File.exists?('Gemfile')).to be true
        expect(File.readlines('Gemfile').grep(/pdqtest/).any?).to be true
      end
    end
  end


end
<commit_msg>remove reference to local file<commit_after>require "spec_helper"
require "pdqtest/skeleton"
require "fileutils"
require "pp"
require 'fakefs/safe'

describe PDQTest::Skeleton do

  before do
    # copy in the whole project folder to a location identical to the current directory
    # so that the skeleton files can be loaded, since fakefs prevents access to
    # the real ones
    pwd = Dir.pwd
    config = File.expand_path('.')
    FakeFS::FileSystem.clone(config, pwd)
  end

  it "removes fixtures.yml" do
    config = File.expand_path('./spec/fixtures/blank_module')
    FakeFS::FileSystem.clone(config, '/apache')

    FakeFS do
      Dir.chdir('/apache') do
        FileUtils.touch '.fixtures.yml'

        PDQTest::Skeleton.init
        # ..to be_an_existing_file doesn't work with fakefs...
        expect(File.exists?('.fixtures.yml')).to be false
        expect(File.exists?('.fixtures.yml.pdqtest_old')).to be true
      end
    end
  end

  it "creates testcase directory structure correctly" do
    config = File.expand_path('./spec/fixtures/blank_module')
    FakeFS::FileSystem.clone(config, '/apache')

    FakeFS do
      Dir.chdir('/apache') do
        PDQTest::Skeleton.init

        expect(Dir.exists?('./spec')).to be true
        expect(Dir.exists?('./spec/acceptance')).to be true
        expect(Dir.exists?('./spec/classes')).to be true
        expect(Dir.exists?('./examples')).to be true
      end
    end
  end

  it "creates skeleton files if required" do
    config = File.expand_path('./spec/fixtures/blank_module')
    FakeFS::FileSystem.clone(config, '/apache')

    FakeFS do
      Dir.chdir('/apache') do
        PDQTest::Skeleton.init
        expect(File.exists?('Rakefile')).to be true
        expect(File.exists?(File.join('spec', 'spec_helper.rb'))).to be true
        expect(File.exists?('Rakefile.pdqtest_old')).to be true
        expect(File.exists?(File.join('spec', 'spec_helper.rb.pdqtest_old'))).to be true
        expect(File.exists?(File.join('spec', 'acceptance', 'init__setup.sh'))).to be true
        expect(File.exists?(File.join('spec', 'acceptance', 'init__before.bats'))).to be true
        expect(File.exists?(File.join('spec', 'acceptance', 'init.bats'))).to be true
        expect(File.exists?(File.join('examples', 'init.pp'))).to be true
        expect(File.exists?('Gemfile')).to be true
        expect(File.readlines('Gemfile').grep(/pdqtest/).any?).to be true
      end
    end
  end


end

{'fraction_non_alphanumeric': 0.14722445695897024, 'fraction_numerical': 0.0, 'mean_word_length': 3.0930041152263374, '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': '494199', 'n_tokens_mistral': 1616, 'n_tokens_neox': 1582, 'n_words': 348}