<commit_before>require 'spec_helper'

describe Twigg::Repo do
  describe '#commits' do
    subject { described_class.new(repo).commits }

    context 'with an empty commit message' do
      let(:repo) do
        scratch_repo do
          `echo foo > bar`
          `git add bar`
          `git commit --allow-empty-message -m ''`
        end
      end

      it 'includes the commit with the empty message' do
        subject.length.should == 1
        subject.first.should be_a(Twigg::Commit)
      end
    end

    context 'with an empty commit' do
      let(:repo) do
        scratch_repo do
          `git commit --allow-empty -m 'Empty'`<commit_msg>Add specs for Twigg::Repo#initialize<commit_after>require 'spec_helper'
require 'tmpdir'

describe Twigg::Repo do
  describe '#initialize' do
    subject { described_class.new(repo) }

    context 'with a valid repo' do
      let(:repo) { scratch_repo }

      it 'returns a working instance' do
        subject.should be_a(Twigg::Repo)
      end
    end

    context 'with an invalid "repo"' do
      let(:repo) { Dir.mktmpdir }

      it 'complains' do
        expect { subject }.to raise_error(Twigg::Repo::InvalidRepoError)
      end
    end

    context 'with a non-directory path' do
      let(:repo) { File.expand_path(__FILE__) }

      it 'complains' do
        expect { subject }.to raise_error(Twigg::Repo::InvalidRepoError)
      end
    end

    context 'with a non-existent path' do
      let(:repo) { File.join(Dir.mktmpdir, 'non-existent') }

      it 'complains' do
        expect { subject }.to raise_error(Twigg::Repo::InvalidRepoError)
      end
    end
  end

  describe '#commits' do
    subject { described_class.new(repo).commits }

    context 'with an empty commit message' do
      let(:repo) do
        scratch_repo do
          `echo foo > bar`
          `git add bar`
          `git commit --allow-empty-message -m ''`
        end
      end

      it 'includes the commit with the empty message' do
        subject.length.should == 1
        subject.first.should be_a(Twigg::Commit)
      end
    end

    context 'with an empty commit' do
      let(:repo) do
        scratch_repo do
          `git commit --allow-empty -m 'Empty'`
{'fraction_non_alphanumeric': 0.09796839729119639, 'fraction_numerical': 0.0009029345372460496, 'mean_word_length': 2.2209302325581395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7519088', 'n_tokens_mistral': 689, 'n_tokens_neox': 672, 'n_words': 206}