Sha256: 180298755b5a540b9e8c544cfc3aa37323513491cb6148a5f97be5d8f9a4998e

Contents?: true

Size: 707 Bytes

Versions: 2

Compression:

Stored size: 707 Bytes

Contents

# coding: utf-8
require 'spec_helper'

describe WordScoop do
  before(:each) do
    keywords = %w|ninja 忍者|
    @tree = WordScoop.new(keywords)
  end

  context "#serch" do
    it "pickup keywords" do
      pickup = @tree.search("I am a ninja. 私は忍者です。Are you a ninja?")
      expect(pickup).to eq(%w|ninja 忍者 ninja|)
    end
  end

  context "#filter_html" do
    it "add link to keywords" do
      text = "I am a ninja. 私は忍者です。Are you a ninja?"
      html = @tree.filter_html(text)
      expect(html).to eq(
        text.gsub(/ninja|忍者/) do |keyword|
          "<a href='http://ja.wikipedia.org/wiki/#{keyword}'>#{keyword}</a>"
        end
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
word_scoop-2.1.1 spec/unit/word_scoop_spec.rb
word_scoop-2.1.0 spec/unit/word_scoop_spec.rb