<commit_before>require 'fasttrack'
require 'open3'

describe Fasttrack::File do
  before do
    @test_file = File.join(__FILE__,'..','data','test.rtf')
  end

  it 'should not leak filehandles' do
    out, _ = Open3.capture2e("lsof")
    assert(!out.include?('test.rtf'))
    assert_raises Exempi::ExempiError do
      Fasttrack::File.new(@test_file)
    end
    out, _ = Open3.capture2e("lsof")
    assert(!out.include?('test.rtf'))
  end
end<commit_msg>Changed test cases to use MiniTest::Mock<commit_after>require 'fasttrack'
require 'open3'

describe Fasttrack::File do
  before do
    @test_file = File.join(__FILE__,'..','data','test.rtf')
  end

  it 'should not leak filehandles' do
    exempi_mock = MiniTest::Mock.new
    exempi_mock.expect(:xmp_files_open, false, [])
    exempi_mock.expect(:xmp_files_free, true, [])
    Exempi.stub(:xmp_files_open, false) { exempi_mock.xmp_files_open }
    Exempi.stub(:xmp_files_free, true) { exempi_mock.xmp_files_free }

    assert_raises Exempi::ExempiError do
      Fasttrack::File.new(@test_file)
    end
    exempi_mock.verify
  end
end
{'fraction_non_alphanumeric': 0.13302752293577982, 'fraction_numerical': 0.005504587155963303, 'mean_word_length': 4.270531400966184, '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': '2858433', 'n_tokens_mistral': 407, 'n_tokens_neox': 407, 'n_words': 73}