<commit_before>require 'spec_helper'
require 'git_tracker/prepare_commit_message'

describe GitTracker::PrepareCommitMessage do
  subject(:prepare_commit_message) { GitTracker::PrepareCommitMessage }

  describe '.run' do
    let(:hook) { double('PrepareCommitMessage') }
    before do
      prepare_commit_message.stub(:new) { hook }
    end

    it 'runs the hook' do
      hook.should_receive(:run)
      prepare_commit_message.run('FILE1', 'hook_source', 'sha1234')
    end
  end

  describe '.new' do

    it 'requires the name of the commit message file' do
      expect { prepare_commit_message.new }.to raise_error(ArgumentError)
    end

    it 'remembers the name of the commit message file' do
      expect(prepare_commit_message.new('FILE1').file).to eq('FILE1')
    end

    it 'optionally accepts a message source' do
      expect(hook = prepare_commit_message.new('FILE1', 'merge').source).to eq('merge')
    end

    it 'optionally accepts the SHA-1 of a commit' do
      expect(hook = prepare_commit_message.new('FILE1', 'commit', 'abc1234').commit_sha).to eq('abc1234')
    end
  end

  describe '#run' do
    let(:hook) { GitTracker::PrepareCommitMessage.new('FILE1') }
    let(:commit_message) { double('CommitMessage', append: nil) }

    before do<commit_msg>Fix for 1.8 hash syntax<commit_after>require 'spec_helper'
require 'git_tracker/prepare_commit_message'

describe GitTracker::PrepareCommitMessage do
  subject(:prepare_commit_message) { GitTracker::PrepareCommitMessage }

  describe '.run' do
    let(:hook) { double('PrepareCommitMessage') }
    before do
      prepare_commit_message.stub(:new) { hook }
    end

    it 'runs the hook' do
      hook.should_receive(:run)
      prepare_commit_message.run('FILE1', 'hook_source', 'sha1234')
    end
  end

  describe '.new' do

    it 'requires the name of the commit message file' do
      expect { prepare_commit_message.new }.to raise_error(ArgumentError)
    end

    it 'remembers the name of the commit message file' do
      expect(prepare_commit_message.new('FILE1').file).to eq('FILE1')
    end

    it 'optionally accepts a message source' do
      expect(hook = prepare_commit_message.new('FILE1', 'merge').source).to eq('merge')
    end

    it 'optionally accepts the SHA-1 of a commit' do
      expect(hook = prepare_commit_message.new('FILE1', 'commit', 'abc1234').commit_sha).to eq('abc1234')
    end
  end

  describe '#run' do
    let(:hook) { GitTracker::PrepareCommitMessage.new('FILE1') }
    let(:commit_message) { double('CommitMessage', :append => nil) }

    before do
{'fraction_non_alphanumeric': 0.1145631067961165, 'fraction_numerical': 0.015533980582524271, 'mean_word_length': 3.9066666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6952726', 'n_tokens_mistral': 823, 'n_tokens_neox': 791, 'n_words': 203}