File: simple_test.rb

package info (click to toggle)
raspell 1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 208 kB
  • ctags: 125
  • sloc: ansic: 439; ruby: 81; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,063 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
$:.unshift(File.dirname(__FILE__) + "/../lib/")

require 'test/unit'
require "raspell"

class TestSpell < Test::Unit::TestCase

  def setup
    @aspell = Aspell.new("en")
    @text = ["Hiere is somthing wrong on the planett. And it was not the Apollo."]
  end

  def test_correct_lines
    assert_equal(["<wrong word> is <wrong word> wrong on the <wrong word>. And it was not the Apollo."],
                 @aspell.correct_lines(@text) { |word| "<wrong word>" })
  end

  def test_list_mispelled
    misspelled = @aspell.list_misspelled(@text).sort
    assert_equal(3, misspelled.length)
  end

  def test_suggest
    suggestions =  @aspell.suggest("spel")
    assert_equal [],
      ["spell", "spiel", "spew", "Opel", "spec", "sped"] - suggestions
  end

  def test_check
    assert_equal(false, @aspell.check("spel"))
    assert(@aspell.check("spell"))
  end

  def test_argument_checking
    assert_raises TypeError do
      @aspell.list_misspelled "Not an array"
    end
    assert_raises TypeError do
      @aspell.list_misspelled [123]
    end
  end
end