<commit_before>require 'spec_helper'

describe SimplePredicate do

  let (:pred_string) { '<SimplePredicate field="f33" operator="lessOrEqual" value="18.8513846048894"/>' }
  let (:pred_xml) { Nokogiri::XML(pred_string); }
  let (:numerical_predicate) { SimplePredicate.new(pred_xml.children.first) }

  it 'returns true' do
    expect(numerical_predicate.true?(f33: 18)).to eq true
  end

  it 'returns false' do
    expect(numerical_predicate.true?(f33: 19)).to eq false
  end

end<commit_msg>spec equal, isMissing operators for simple pred<commit_after>require 'spec_helper'

describe SimplePredicate do

  context 'less or equal predicate' do
    let (:pred_string) { '<SimplePredicate field="f33" operator="lessOrEqual" value="18.8513846048894"/>' }
    let (:pred_xml) { Nokogiri::XML(pred_string); }
    let (:predicate) { SimplePredicate.new(pred_xml.children.first) }

    it 'returns true' do
      expect(predicate.true?(f33: 18)).to eq true
    end

    it 'returns false' do
      expect(predicate.true?(f33: 19)).to eq false
    end
  end

  context 'is missing predicate' do
    let (:pred_string) { '<SimplePredicate field="f33" operator="isMissing"/>' }
    let (:pred_xml) { Nokogiri::XML(pred_string); }
    let (:predicate) { SimplePredicate.new(pred_xml.children.first) }

    it 'returns true' do
      expect(predicate.true?(f33: nil)).to eq true
    end

    it 'returns false' do
      expect(predicate.true?({})).to eq true
    end

    it 'returns false' do
      expect(predicate.true?(f33: '6')).to eq false
    end
  end

  context 'equals predicate' do
    let (:pred_string) { '<SimplePredicate field="f33" operator="equal" value="f2v3"/>' }
    let (:pred_xml) { Nokogiri::XML(pred_string); }
    let (:predicate) { SimplePredicate.new(pred_xml.children.first) }

    it 'returns true' do
      expect(predicate.true?(f33: 'f2v3')).to eq true
    end

    it 'returns true' do
      expect(predicate.true?(f33: nil)).to eq false
    end

    it 'returns false' do
      expect(predicate.true?({})).to eq false
    end
  end

end
{'fraction_non_alphanumeric': 0.1348859776807375, 'fraction_numerical': 0.032508491023774864, 'mean_word_length': 3.7731481481481484, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '3601954', 'n_tokens_mistral': 756, 'n_tokens_neox': 698, 'n_words': 170}