Sha256: 766e4accb847fe8cf5c8049821eb2b55779a348f6166e5d73df7e7f7b8c8381b

Contents?: true

Size: 1.4 KB

Versions: 22

Compression:

Stored size: 1.4 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../helpers/model_test_helper')

class SearchUnitTest < ModelTestCase
  include DataCatalog

  context "tokens" do
    test "spaces" do
      assert_equal %w(hello world), Search.tokens("hello world")
    end

    test "commas" do
      assert_equal %w(red white blue), Search.tokens("red, white, blue")
    end

    test "periods" do
      assert_equal %w(flood plain data), Search.tokens("Flood plain data.")
    end

    test "integers" do
      assert_equal %w(99 barrels of beer), Search.tokens("99 barrels of beer")
    end

    test "floating point" do
      assert_equal %w(the earth has an axial tilt of 23.439 degrees),
        Search.tokens("The earth has an axial tilt of 23.439 degrees.")
    end
  end
  
  context "tokenize" do
    test "simple" do
      assert_equal %w(aerospace defense systems),
        Search.tokenize(["aerospace defense", "defense systems"])
    end
  end
  
  context "unstop" do
    test "simple" do
      assert_equal %w(big brown fox), Search.unstop(%w(the big brown fox))
    end
  end
  
  context "process" do
    test "simple" do
      assert_equal %w(aerospace defense systems),
        Search.process(["the aerospace defense", "systems of defense"])
    end

    test "complex" do
      assert_equal %w(earth has axial tilt 23.439 degrees),
        Search.process(["The earth has an axial tilt of 23.439 degrees."])
    end
  end
  
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
sinatra_resource-0.4.21 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.20 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.19 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.18 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.17 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.16 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.15 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.14 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.13 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.12 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.11 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.10 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.9 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.8 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.7 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.6 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.5 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.4 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.3 examples/datacatalog/test/models/search_test.rb
sinatra_resource-0.4.2 examples/datacatalog/test/models/search_test.rb