Sha256: 2487746d6823066d7c1df6114de822b7c2212f9f2e70ebf901942e40f3143d96

Contents?: true

Size: 1.75 KB

Versions: 6

Compression:

Stored size: 1.75 KB

Contents

require 'spec/spec_helper'

describe ThinkingSphinx::Index do
  describe "generated sql_query" do
    it "should include explicit groupings if requested" do
      @index = ThinkingSphinx::Index.new(Person)
      
      @index.groupings << "custom_sql"
      @index.to_riddle_for_core(0, 0).sql_query.should match(/GROUP BY.+custom_sql/)
    end
  end
  
  describe "prefix_fields method" do
    before :each do
      @index = ThinkingSphinx::Index.new(Person)
      
      @field_a = ThinkingSphinx::Field.stub_instance(:prefixes => true)
      @field_b = ThinkingSphinx::Field.stub_instance(:prefixes => false)
      @field_c = ThinkingSphinx::Field.stub_instance(:prefixes => true)
      
      @index.fields = [@field_a, @field_b, @field_c]
    end
    
    it "should return fields that are flagged as prefixed" do
      @index.prefix_fields.should include(@field_a)
      @index.prefix_fields.should include(@field_c)
    end
    
    it "should not return fields that aren't flagged as prefixed" do
      @index.prefix_fields.should_not include(@field_b)
    end
  end
  
  describe "infix_fields method" do
    before :each do
      @index = ThinkingSphinx::Index.new(Person)
      
      @field_a = ThinkingSphinx::Field.stub_instance(:infixes => true)
      @field_b = ThinkingSphinx::Field.stub_instance(:infixes => false)
      @field_c = ThinkingSphinx::Field.stub_instance(:infixes => true)
      
      @index.fields = [@field_a, @field_b, @field_c]
    end
    
    it "should return fields that are flagged as infixed" do
      @index.infix_fields.should include(@field_a)
      @index.infix_fields.should include(@field_c)
    end
    
    it "should not return fields that aren't flagged as infixed" do
      @index.infix_fields.should_not include(@field_b)
    end
  end
end

Version data entries

6 entries across 6 versions & 4 rubygems

Version Path
dpickett-thinking-sphinx-1.1.4 spec/unit/thinking_sphinx/index_spec.rb
freelancing-god-thinking-sphinx-1.1.3 spec/unit/thinking_sphinx/index_spec.rb
freelancing-god-thinking-sphinx-1.1.4 spec/unit/thinking_sphinx/index_spec.rb
freelancing-god-thinking-sphinx-1.1.5 spec/unit/thinking_sphinx/index_spec.rb
pixeltrix-thinking-sphinx-1.1.5 spec/unit/thinking_sphinx/index_spec.rb
sherpa99-thinking-sphinx-1.1.4 spec/unit/thinking_sphinx/index_spec.rb