Sha256: 404ac3fba6a4b71d95d85ae0e1a0a25a45134d1ff2252c40460b625154b652f6

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

# encoding: utf-8
module ThinkingSphinx; end

require './lib/thinking_sphinx/wildcard'

describe ThinkingSphinx::Wildcard do
  describe '.call' do
    it "does not star quorum operators" do
      ThinkingSphinx::Wildcard.call("foo/3").should == "*foo*/3"
    end

    it "does not star proximity operators or quoted strings" do
      ThinkingSphinx::Wildcard.call(%q{"hello world"~3}).
        should == %q{"hello world"~3}
    end

    it "treats slashes as a separator when starring" do
      ThinkingSphinx::Wildcard.call("a\\/c").should == "*a*\\/*c*"
    end

    it "separates escaping from the end of words" do
      ThinkingSphinx::Wildcard.call("\\(913\\)").should == "\\(*913*\\)"
    end

    it "ignores escaped slashes" do
      ThinkingSphinx::Wildcard.call("\\/\\/pan").should == "\\/\\/*pan*"
    end

    it "does not star manually provided field tags" do
      ThinkingSphinx::Wildcard.call("@title pan").should == "@title *pan*"
    end

    it "does not star manually provided arrays of field tags" do
      ThinkingSphinx::Wildcard.call("@(title, body) pan").
        should == "@(title, body) *pan*"
    end

    it "handles nil queries" do
      ThinkingSphinx::Wildcard.call(nil).should == ''
    end

    it "handles unicode values" do
      ThinkingSphinx::Wildcard.call('älytön').should == '*älytön*'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thinking-sphinx-3.2.0 spec/thinking_sphinx/wildcard_spec.rb
thinking-sphinx-3.1.4 spec/thinking_sphinx/wildcard_spec.rb
thinking-sphinx-3.1.3 spec/thinking_sphinx/wildcard_spec.rb
thinking-sphinx-3.1.2 spec/thinking_sphinx/wildcard_spec.rb
thinking-sphinx-3.1.1 spec/thinking_sphinx/wildcard_spec.rb