<commit_before>require 'rspec/expectations'

## matcher to validate if all elements in list are equals
RSpec::Matchers.define :all_list_elements_eq do |expected|
  match do |actual|
    actual.each do |i|
      expect(i).to eq(expected)
    end
  end
  failure_message_for_should do |actual|
    "expected that all elements in #{actual} list would be equals #{expected}"
  end
end

RSpec::Matchers.define :visual_match do |expected|
  match do |actual|
    base_path = File.expand_path(".", Dir.pwd) + '/screenshots/'
    file_atual = File.join(base_path, 'current_images/') + actual + '.png'
    file_baseline = File.join(base_path, 'baseline/') + expected + '.png'
    file_diff = File.join(base_path, 'diffs/') + actual + '_diff_' + expected + '.png'
    comparacao = IMATCHER.compare(file_atual, file_baseline)
    @score = comparacao.score
    if comparacao.match? != true
      comparacao.difference_image.save(file_diff)
    end
    expect(comparacao.match?).to be true
  end
  failure_message_for_should do |actual|
    "expected that two images are equals, but they are #{@score} different"
  end
end<commit_msg>Translating var 'comparacao' to english<commit_after>require 'rspec/expectations'

## matcher to validate if all elements in list are equals
RSpec::Matchers.define :all_list_elements_eq do |expected|
  match do |actual|
    actual.each do |i|
      expect(i).to eq(expected)
    end
  end
  failure_message_for_should do |actual|
    "expected that all elements in #{actual} list would be equals #{expected}"
  end
end

RSpec::Matchers.define :visual_match do |expected|
  match do |actual|
    base_path = File.expand_path(".", Dir.pwd) + '/screenshots/'
    file_atual = File.join(base_path, 'current_images/') + actual + '.png'
    file_baseline = File.join(base_path, 'baseline/') + expected + '.png'
    file_diff = File.join(base_path, 'diffs/') + actual + '_diff_' + expected + '.png'
    comparison = IMATCHER.compare(file_atual, file_baseline)
    @score = comparison.score
    if comparison.match? != true
      comparison.difference_image.save(file_diff)
    end
    expect(comparison.match?).to be true
  end
  failure_message_for_should do |actual|
    "expected that two images are equals, but they are #{@score} different"
  end
end
{'fraction_non_alphanumeric': 0.1146384479717813, 'fraction_numerical': 0.0, 'mean_word_length': 4.008830022075055, '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': '5037294', 'n_tokens_mistral': 745, 'n_tokens_neox': 732, 'n_words': 203}