Sha256: 573bbf9523cfbfe67b85c8cbd654a40a4577f1bc11cd0f9527233477d3cc92c1

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'unit_test_helper.rb'
include ActsAsIndexed

class TokenNormalizerTest < ActiveSupport::TestCase

  def test_leaves_case_of_tokens_untouched
    assert_equal ["Chocolate", "Chip", "Cookies"], TokenNormalizer.process(["Chocolate", "Chip", "Cookies"])
  end

  def test_downcases_tokens
    assert_equal ["chocolate", "chip", "cookies"], TokenNormalizer.process(["Chocolate", "Chip", "Cookies"], :normalize_case => true)
  end

  def test_limits_min_length_to_five
    assert_equal ["Chocolate", "Cookies"], TokenNormalizer.process(["Chocolate", "Chip", "Cookies"], :min_token_length => 5)
  end

  def test_limits_min_length_to_four
    assert_equal ["Love", "Chocolate", "Chip", "Cookies"], TokenNormalizer.process(["I", "Love", "Chocolate", "Chip", "Cookies"], :min_token_length => 4)
  end

  def test_downcases_and_limits_min_length_to_four
    assert_equal ["love", "chocolate", "chip", "cookies"], TokenNormalizer.process(["I", "Love", "Chocolate", "Chip", "Cookies"], :normalize_case => true, :min_token_length => 4)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
acts_as_indexed-0.9.0 test/unit/token_normalizer_test.rb
acts_as_indexed-0.8.3 test/unit/token_normalizer_test.rb
acts_as_indexed-0.8.2 test/unit/token_normalizer_test.rb