Sha256: 11abd3be7e720bc9d319e5ca406d57661b5640280fbb1955464e56cbe2773f1a
Contents?: true
Size: 1.17 KB
Versions: 11
Compression:
Stored size: 1.17 KB
Contents
require "test_helper" module CensorBear class StopWordTest < ActiveSupport::TestCase test "could create stop_word" do model = FactoryBot.create(:stop_word) assert_equal model.present?, true end test "could match when content hit the ruler" do stop_word = FactoryBot.create(:stop_word, ugc: "replace", key: "hello", replacement: "goodbye") content = "ignore" answer = StopWord.check!(content, "ugc", **{}) assert_equal false, answer.hit end test 'replace the content when ugc is "replace"' do stop_word = FactoryBot.create(:stop_word, ugc: "replace", key: "hello", replacement: "goodbye") content = "hello world" answer = StopWord.check!(content, "ugc", **{}) assert_equal "goodbye world", answer.filtered end test "could replace the content when have more than one stop words" do FactoryBot.create(:stop_word, ugc: "replace", key: "hello", replacement: "goodbye") FactoryBot.create(:stop_word, ugc: "replace", key: "world", replacement: "my friends") answer = StopWord.check!("hello world", "ugc", **{}) assert_equal "goodbye my friends", answer.filtered end end end
Version data entries
11 entries across 11 versions & 1 rubygems