<commit_before>require 'spec_helper'

describe Morph::DockerRunner do
  describe ".add_config_defaults_to_directory" do
    before(:each) do
      FileUtils.mkdir("test")
      FileUtils.touch("test/scraper.rb")
    end
    after(:each) { FileUtils.rm_rf("test") }

    context "a set of files" do
      before :each do
        FileUtils.touch("test/Procfile")
        FileUtils.touch("test/Gemfile")
        FileUtils.touch("test/Gemfile.lock")
      end

      it do
        Dir.mktmpdir do |dir|
          Morph::Runner.add_config_defaults_to_directory("test", dir)
          Dir.entries(dir).sort.should == [".", "..", "Gemfile", "Gemfile.lock", "Procfile", "scraper.rb"]
          File.read(File.join(dir, "Gemfile")).should == ""
          File.read(File.join(dir, "Gemfile.lock")).should == ""
          File.read(File.join(dir, "Procfile")).should == File.read(Morph::Language.new(:ruby).default_config_file_path("Procfile"))
        end
      end
    end

    context "another set of files" do
      before :each do
        FileUtils.touch("test/Gemfile")
        FileUtils.touch("test/Gemfile.lock")
      end

      it do
        Dir.mktmpdir do |dir|
          Morph::Runner.add_config_defaults_to_directory("test", dir)
          Dir.entries(dir).sort.should == [".", "..", "Gemfile", "Gemfile.lock", "Procfile", "scraper.rb"]
          File.read(File.join(dir, "Gemfile")).should == ""
          File.read(File.join(dir, "Gemfile.lock")).should == ""
          File.read(File.join(dir, "Procfile")).should == File.read(Morph::Language.new(:ruby).default_config_file_path("Procfile"))
        end
      end
    end

    context "user tries to override Procfile" do
      before :each do
        File.open("test/Procfile", "w") {|f| f << "scraper: some override"}
      end

      it do
        Dir.mktmpdir do |dir|
          Morph::Runner.add_config_defaults_to_directory("test", dir)
          Dir.entries(dir).sort.should == [".", "..", "Gemfile", "Gemfile.lock", "Procfile", "scraper.rb"]
          ruby = Morph::Language.new(:ruby)
          File.read(File.join(dir, "Gemfile")).should == File.read(ruby.default_config_file_path("Gemfile"))
          File.read(File.join(dir, "Gemfile.lock")).should == File.read(ruby.default_config_file_path("Gemfile.lock"))
          File.read(File.join(dir, "Procfile")).should == File.read(ruby.default_config_file_path("Procfile"))
        end
      end
    end
  end
end<commit_msg>Remove one of two similar tests<commit_after>require 'spec_helper'

describe Morph::DockerRunner do
  describe ".add_config_defaults_to_directory" do
    before(:each) do
      FileUtils.mkdir("test")
      FileUtils.touch("test/scraper.rb")
    end
    after(:each) { FileUtils.rm_rf("test") }

    context "user tries to override Procfile" do
      before :each do
        File.open("test/Procfile", "w") {|f| f << "scraper: some override"}
        FileUtils.touch("test/Gemfile")
        FileUtils.touch("test/Gemfile.lock")
      end

      it do
        Dir.mktmpdir do |dir|
          Morph::Runner.add_config_defaults_to_directory("test", dir)
          Dir.entries(dir).sort.should == [".", "..", "Gemfile", "Gemfile.lock", "Procfile", "scraper.rb"]
          File.read(File.join(dir, "Gemfile")).should == ""
          File.read(File.join(dir, "Gemfile.lock")).should == ""
          File.read(File.join(dir, "Procfile")).should == File.read(Morph::Language.new(:ruby).default_config_file_path("Procfile"))
        end
      end
    end

    context "another set of files" do
      before :each do
        FileUtils.touch("test/Gemfile")
        FileUtils.touch("test/Gemfile.lock")
      end

      it do
        Dir.mktmpdir do |dir|
          Morph::Runner.add_config_defaults_to_directory("test", dir)
          Dir.entries(dir).sort.should == [".", "..", "Gemfile", "Gemfile.lock", "Procfile", "scraper.rb"]
          File.read(File.join(dir, "Gemfile")).should == ""
          File.read(File.join(dir, "Gemfile.lock")).should == ""
          File.read(File.join(dir, "Procfile")).should == File.read(Morph::Language.new(:ruby).default_config_file_path("Procfile"))
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.16301995672036548, 'fraction_numerical': 0.0, 'mean_word_length': 2.830570902394107, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2620242', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1373, 'n_words': 227}