<commit_before>namespace :refinery do
  namespace :testing do
    desc "Generates a dummy app for testing"
    task :dummy_app do
      unless dummy_app_path.exist?
        Rake::Task["refinery:testing:setup_dummy_app"].invoke
        Rake::Task["refinery:testing:setup_extension"].invoke
        Rake::Task["refinery:testing:init_test_database"].invoke
      end
    end

    task :setup_dummy_app do
      require 'refinerycms'

      params = %w(--quiet)
      params << "--database=#{ENV['DB']}" if ENV['DB']

      Refinery::DummyGenerator.start params

      Refinery::CmsGenerator.start %w[--quiet --fresh-installation]

      Dir.chdir Refinery::Testing::Railtie.target_extension_path
    end

    # This task is a hook to allow extensions to pass configuration
    # Just define this inside your extension's Rakefile or a .rake file
    # and pass arbitrary code. Example:
    #
    # namespace :refinery do
    #   namespace :testing do
    #     task :setup_extension do
    #       require 'refinerycms-my-extension'
    #       Refinery::MyEngineGenerator.start %w[--quiet]
    #     end
    #   end
    # end
    task :setup_extension do
    end

    desc "Remove the dummy app used for testing"
    task :clean_dummy_app do
      dummy_app_path.rmtree if dummy_app_path.exist?
    end

    task :init_test_database do
      load 'rails/tasks/engine.rake'
      Rake::Task["app:db:test:prepare"].invoke
    end

    def dummy_app_path
      Refinery::Testing::Railtie.target_extension_path.join('spec', 'dummy')
    end
  end
end
<commit_msg>Added a testing task which clears the database before generating the application for DBs such as s mysql or postgres where the tables may already exist and therefore fail at life.<commit_after>namespace :refinery do
  namespace :testing do
    desc "Generates a dummy app for testing"
    task :dummy_app do
      unless dummy_app_path.exist?
        Rake::Task["refinery:testing:setup_dummy_app"].invoke
        Rake::Task["refinery:testing:setup_extension"].invoke
        Rake::Task["refinery:testing:init_test_database"].invoke
      end
    end

    task :setup_dummy_app do
      require 'refinerycms'

      params = %w(--quiet)
      params << "--database=#{ENV['DB']}" if ENV['DB']

      Refinery::DummyGenerator.start params

      # Ensure the database is not there from a previous run.
      Rake::Task['refinery:testing:drop_dummy_app_database'].invoke

      Refinery::CmsGenerator.start %w[--quiet --fresh-installation]

      Dir.chdir Refinery::Testing::Railtie.target_extension_path
    end

    # This task is a hook to allow extensions to pass configuration
    # Just define this inside your extension's Rakefile or a .rake file
    # and pass arbitrary code. Example:
    #
    # namespace :refinery do
    #   namespace :testing do
    #     task :setup_extension do
    #       require 'refinerycms-my-extension'
    #       Refinery::MyEngineGenerator.start %w[--quiet]
    #     end
    #   end
    # end
    task :setup_extension do
    end

    desc "Remove the dummy app used for testing"
    task :clean_dummy_app do
      Rake::Task['refinery:testing:drop_dummy_app_database'].invoke
      dummy_app_path.rmtree if dummy_app_path.exist?
    end

    desc "Remove the dummy app's database."
    task :drop_dummy_app_database do
      load 'rails/tasks/engine.rake'
      Rake::Task['app:db:drop'].invoke
    end

    task :init_test_database do
      load 'rails/tasks/engine.rake'
      Rake::Task['app:db:test:prepare'].invoke
    end

    def dummy_app_path
      Refinery::Testing::Railtie.target_extension_path.join('spec', 'dummy')
    end
  end
end

{'fraction_non_alphanumeric': 0.09387867142465002, 'fraction_numerical': 0.0, 'mean_word_length': 2.995614035087719, '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': '5817661', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1072, 'n_words': 291}