<commit_before>require 'spec_helper'
require 'inci_score/computer'

describe InciScore::Computer do
  let(:computer) { InciScore::Computer::new(src: Stubs::Computer::ingredients, catalog: Stubs::Computer::catalog) }

  it 'must collect components' do
    computer.call.components.must_equal({"aqua"=>0, "disodium laureth sulfosuccinate"=>2, "cocamidopropyl betaine"=>1, "disodium cocoamphodiacetate"=>0, "glyceryl laurate"=>0, "peg-7 glyceryl cocoate"=>3, "sodium lactate"=>0, "parfum"=>0, "niacinamide"=>0, "glycine"=>0, "magnesium aspartate"=>0, "alanine"=>0, "lysine"=>0, "leucine"=>0, "allantoin"=>0, "peg-150 distearate"=>3, "peg-120 methyl glucose dioleate"=>3, "phenoxyethanol"=>2, "ci 61570"=>3})
  end

  it 'must collect unrecognized components' do
    computer.call.unrecognized.must_equal %w[50]
  end

  it 'must detect valid state' do
    assert computer.call.valid
  end

  it 'must detect invalid state' do
    computer = InciScore::Computer::new(src: 'ingredients: aqua, noent1, noent2', catalog: Stubs::Computer::catalog)
    refute computer.call.valid
  end

  it 'must compute the score' do
    computer.call.score.must_equal 82.52110249964151
  end
end
<commit_msg>Mike - silence warn on computer spec<commit_after>require 'spec_helper'
require 'inci_score/computer'

describe InciScore::Computer do
  let(:computer) { InciScore::Computer::new(src: Stubs::Computer::ingredients, catalog: Stubs::Computer::catalog) }

  it 'must collect components' do
    computer.call.components.must_equal({"aqua"=>0, "disodium laureth sulfosuccinate"=>2, "cocamidopropyl betaine"=>1, "disodium cocoamphodiacetate"=>0, "glyceryl laurate"=>0, "peg-7 glyceryl cocoate"=>3, "sodium lactate"=>0, "parfum"=>0, "niacinamide"=>0, "glycine"=>0, "magnesium aspartate"=>0, "alanine"=>0, "lysine"=>0, "leucine"=>0, "allantoin"=>0, "peg-150 distearate"=>3, "peg-120 methyl glucose dioleate"=>3, "phenoxyethanol"=>2, "ci 61570"=>3})
  end

  it 'must collect unrecognized components' do
    computer.call.unrecognized.must_equal %w[50]
  end

  it 'must detect valid state' do
    assert computer.call.valid
  end

  it 'must detect invalid state' do
    computer = InciScore::Computer::new(src: 'ingredients: aqua, noent1, noent2', catalog: Stubs::Computer::catalog)
    def computer.warn(msg); end
    refute computer.call.valid
  end

  it 'must compute the score' do
    computer.call.score.must_equal 82.52110249964151
  end
end

{'fraction_non_alphanumeric': 0.14956736711990112, 'fraction_numerical': 0.042027194066749075, 'mean_word_length': 5.858757062146893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, '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': '1838197', 'n_tokens_mistral': 988, 'n_tokens_neox': 842, 'n_words': 200}