<commit_before>require 'spec_helper'

RSpec.describe Judge do
  subject { described_class }

  describe '.score' do
    it 'scores a query against a potential match' do
      query = 'spec/foo/bar/car_spec.rb'
      potential_match = 'foo/bar/zar.rb'
      score = subject.score(query, potential_match)
      expect(score).to be_within(0.0001).of(0.5714)
    end

    it 'finds the longest common substring' do
      query = 'spec/foo/bar/car_spec.rb'
      potential_match = 'foo/bar/zar.rb'
      expect(subject).to receive(:find_longest_common_substring)
        .with(query, potential_match).and_return('foo')
      subject.score(query, potential_match)
    end

    it 'computes the percentage of coverage the common substring has' do
      query = 'spec/foo/bar/car_spec.rb'
      potential_match = 'foo/bar/zar.rb'
      allow(subject).to receive(:find_longest_common_substring)
        .and_return('foo')
      expect(subject.score(query, potential_match)).to be_within(0.0001).of(3.0/14.0)
    end
  end

  describe '.find_longest_common_substring' do
    it 'returns the longest common substring' do
      query = 'spec/foo/bar/car_spec.rb'
      potential_match = 'foo/bar/zar.rb'
      expect(subject.find_longest_common_substring(query, potential_match)).to eq('foo/bar/')
    end
  end
end<commit_msg>Fix Judge specs based on new equation<commit_after>require 'spec_helper'

RSpec.describe Judge do
  subject { described_class }

  describe '.score' do
    it 'scores a query against a potential match' do
      query = 'spec/foo/bar/car_spec.rb'
      potential_match = 'foo/bar/zar.rb'
      score = subject.score(query, potential_match)
      expect(score).to be_within(0.0001).of(0.19047)
    end

    it 'finds the longest common substring' do
      query = 'spec/foo/bar/car_spec.rb'
      potential_match = 'foo/bar/zar.rb'
      expect(subject).to receive(:find_longest_common_substring)
        .with(query, potential_match).and_return('foo')
      subject.score(query, potential_match)
    end

    it 'computes the percentage of coverage the common substring has' do
      query = 'spec/foo/bar/car_spec.rb'
      potential_match = 'foo/bar/zar.rb'
      allow(subject).to receive(:find_longest_common_substring)
        .and_return('foo')
      expect(subject.score(query, potential_match)).to be_within(0.0001).of((3.0/14.0) * (3.0/24.0))
    end
  end

  describe '.find_longest_common_substring' do
    it 'returns the longest common substring' do
      query = 'spec/foo/bar/car_spec.rb'
      potential_match = 'foo/bar/zar.rb'
      expect(subject.find_longest_common_substring(query, potential_match)).to eq('foo/bar/')
    end
  end
end
{'fraction_non_alphanumeric': 0.11385767790262172, 'fraction_numerical': 0.017228464419475654, 'mean_word_length': 3.280448717948718, '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': '2596812', 'n_tokens_mistral': 914, 'n_tokens_neox': 868, 'n_words': 186}