<commit_before>describe ActiveRecord::ConnectionAdapters::SchemaStatements do
  describe "#index_name_with_simple" do
    let(:index_name) { table_indexes(table_name).first.name }

    context "When auto_shotten is enabled" do
      include_context :setup_database, auto_shorten: true

      context "When single column index" do
        let(:table_name) { "articles" }

        it_is_asserted_by { index_name == "user_id" }
      end

      context "When multiple columns index" do
        let(:table_name) { "user_stocks" }

        it_is_asserted_by { index_name == "user_id_and_article_id" }
      end

      context "When specified index name" do
        let(:table_name) { "comments" }

        it_is_asserted_by { index_name == "comment_index" }
      end
    end

    context "When auto_shotten is disabled" do
      include_context :setup_database, auto_shorten: false

      context "When single column index" do
        let(:table_name) { "articles" }

        it_is_asserted_by { index_name == "index_articles_on_user_id" }
      end

      context "When multiple columns index" do
        let(:table_name) { "user_stocks" }

        it_is_asserted_by { index_name == "index_user_stocks_on_user_id_and_article_id" }
      end

      context "When specified index name" do
        let(:table_name) { "comments" }

        it_is_asserted_by { index_name == "comment_index" }
      end
    end

    def table_indexes(table)
      ActiveRecord::Base.connection.indexes(table)
    end
  end
end<commit_msg>Refactor spec<commit_after>describe ActiveRecord::ConnectionAdapters::SchemaStatements do
  describe "#index_name_with_simple" do
    context "When auto_shotten is enabled" do
      include_context :setup_database, auto_shorten: true

      context "When single column index" do
        it_is_asserted_by { index_name_of(:articles, [:user_id]) == "user_id" }
      end

      context "When multiple columns index" do
        it_is_asserted_by { index_name_of(:user_stocks, [:user_id, :article_id]) == "user_id_and_article_id" }
      end

      context "When specified index name" do
        it_is_asserted_by { index_name_of(:comments, :user_id) == "comment_index" }
      end
    end

    context "When auto_shotten is disabled" do
      include_context :setup_database, auto_shorten: false

      context "When single column index" do
        it_is_asserted_by { index_name_of(:articles, [:user_id]) == "index_articles_on_user_id" }
      end

      context "When multiple columns index" do
        it_is_asserted_by { index_name_of(:user_stocks, [:user_id, :article_id]) == "index_user_stocks_on_user_id_and_article_id" }
      end

      context "When specified index name" do
        it_is_asserted_by { index_name_of(:comments, :user_id) == "comment_index" }
      end
    end

    def table_indexes(table)
      ActiveRecord::Base.connection.indexes(table)
    end

    def index_name_of(table, columns)
      columns = Array.wrap(columns).map(&:to_s)
      table_indexes(table.to_s).find { |index| index.columns == columns }.try(:name)
    end
  end
end
{'fraction_non_alphanumeric': 0.08845528455284553, 'fraction_numerical': 0.0, 'mean_word_length': 3.3081232492997197, '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': '676735', 'n_tokens_mistral': 1005, 'n_tokens_neox': 970, 'n_words': 221}