# frozen_string_literal: true require 'rails_helper' describe WordWatcher do let(:raw) { "Do you like liquorice?\n\nI really like them. One could even say that I am *addicted* to liquorice. Anf if\nyou can mix it up with some anise, then I'm in heaven ;)" } after do $redis.flushall end describe '.word_matcher_regexp' do let!(:word1) { Fabricate(:watched_word, action: WatchedWord.actions[:block]).word } let!(:word2) { Fabricate(:watched_word, action: WatchedWord.actions[:block]).word } context 'format of the result regexp' do it "is correct when watched_words_regular_expressions = true" do SiteSetting.watched_words_regular_expressions = true regexp = WordWatcher.word_matcher_regexp(:block) expect(regexp.inspect).to eq("/(#{word1})|(#{word2})/i") end it "is correct when watched_words_regular_expressions = false" do SiteSetting.watched_words_regular_expressions = false regexp = WordWatcher.word_matcher_regexp(:block) expect(regexp.inspect).to eq("/(?