File: bayesian_redis_test.rb

package info (click to toggle)
ruby-classifier-reborn 2.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,424 kB
  • sloc: ruby: 2,021; makefile: 7
file content (28 lines) | stat: -rw-r--r-- 781 bytes parent folder | download | duplicates (3)
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
# encoding: utf-8

require File.dirname(__FILE__) + '/../test_helper'
require_relative './bayesian_common_tests'

class BayesianRedisTest < Minitest::Test
  include BayesianCommonTests

  def setup
    begin
      @old_stopwords = Hasher::STOPWORDS['en']
      @backend = ClassifierReborn::BayesRedisBackend.new
      @backend.instance_variable_get(:@redis).config(:set, "save", "")
      @alternate_backend = ClassifierReborn::BayesRedisBackend.new(db: 1)
      @classifier = ClassifierReborn::Bayes.new 'Interesting', 'Uninteresting', backend: @backend
    rescue Redis::CannotConnectError => e
      skip(e)
    end
  end

  def teardown
    Hasher::STOPWORDS['en'] = @old_stopwords
    if defined? @backend
      @backend.reset
      @alternate_backend.reset
    end
  end
end