Class: TestDoc

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/test/unit/doc_test.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/test/unit/doc_test.rb', line 5

def setup
  OmniCat.configure do |config|
    config.exclude_tokens = ["was", "at", "by"]
    config.token_patterns = {
      minus: [/[\s\t\n\r]+/, /(@[\w\d]+)/],
      plus: [/[\p{L}\-0-9]{2,}/, /[\!\?]/, /[\:\)\(\;\-\|]{2,3}/]
    }
  end
  @doc = OmniCat::Doc.new(
    content: "omnicat v-01 was written at 2011, omnicat by @mustafaturan"
  )
end

#test_decrement_countObject



30
31
32
33
# File 'lib/test/unit/doc_test.rb', line 30

def test_decrement_count
  @doc.decrement_count
  assert_equal(0, @doc.count)
end

#test_decrement_count_if_zeroObject



35
36
37
38
39
# File 'lib/test/unit/doc_test.rb', line 35

def test_decrement_count_if_zero
  @doc.decrement_count
  @doc.decrement_count
  assert_equal(0, @doc.count)
end

#test_increment_countObject



25
26
27
28
# File 'lib/test/unit/doc_test.rb', line 25

def test_increment_count
  @doc.increment_count
  assert_equal(2, @doc.count)
end

#test_omnicat_tokenizeObject



18
19
20
21
22
23
# File 'lib/test/unit/doc_test.rb', line 18

def test_omnicat_tokenize
  assert_equal(
    {"omnicat" => 2, "v-01" => 1, "written" => 1, "2011" => 1},
    @doc.tokens
  )
end