<commit_before># coding: utf-8

require 'spec_helper'

module Transpec
  describe Git do
    include_context 'isolated environment'

    describe '.command_available?' do
      subject { Git.command_available? }

      context 'when git command is found in PATH' do
        it { should be_true }
      end

      context 'when git command is not found in PATH' do
        before { stub_const('Transpec::Git::GIT', 'non-existent-command') }
        it { should be_false }
      end
    end

    shared_context 'inside of git repository' do
      around do |example|
        Dir.mkdir('repo')
        Dir.chdir('repo') do
          `git init`
          example.run
        end
      end
    end

    describe '.inside_of_repository?' do
      subject { Git.inside_of_repository? }

      context 'when the current directory is inside of git repository' do
        include_context 'inside of git repository'
        it { should be_true }<commit_msg>Fix build error caused by no Git identity configuration<commit_after># coding: utf-8

require 'spec_helper'

module Transpec
  describe Git do
    include_context 'isolated environment'

    if ENV['TRAVIS']
      before do
        system('git config --global user.email "<EMAIL>"')
        system('git config --global user.name "<NAME>"')
      end
    end

    describe '.command_available?' do
      subject { Git.command_available? }

      context 'when git command is found in PATH' do
        it { should be_true }
      end

      context 'when git command is not found in PATH' do
        before { stub_const('Transpec::Git::GIT', 'non-existent-command') }
        it { should be_false }
      end
    end

    shared_context 'inside of git repository' do
      around do |example|
        Dir.mkdir('repo')
        Dir.chdir('repo') do
          `git init`
          example.run
        end
      end
    end

    describe '.inside_of_repository?' do
      subject { Git.inside_of_repository? }

      context 'when the current directory is inside of git repository' do
        include_context 'inside of git repository'
        it { should be_true }
{'fraction_non_alphanumeric': 0.08072174738841406, 'fraction_numerical': 0.000949667616334283, 'mean_word_length': 2.3128930817610063, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1429788', 'n_tokens_mistral': 605, 'n_tokens_neox': 571, 'n_words': 206}