Sha256: 0a7de81436d0f5bce3668e282cbe79fb51ed508bb40468340e90a2e300ca2662

Contents?: true

Size: 738 Bytes

Versions: 7

Compression:

Stored size: 738 Bytes

Contents

require 'spec_helper'

class ActiveModelUserWord < StubModelBase
  ac_field :full_name, :mode => :word
end

describe ':word mode autocomplete' do
  let(:model) { ActiveModelUserWord }

  before :all do
    model.setup_index
  end

  it 'have :word mode' do
    model.ac_opts[:mode].should == :word
  end

  it_behaves_like 'basic autocomplete', ActiveModelUserWord

  it 'don\'t suggest from the middle of the word' do
    model.ac_search('becca').to_a.should be_empty
  end

  it 'suggest for each word of the source' do
    model.ac_search('Flores').map(&:full_name).should == ['Joyce Flores']
  end

  it 'suggest with relevance order' do
    model.ac_search('Lau').map(&:full_name).should == ['Laura Larson', 'Larson Laura']
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
elasticsearch_autocomplete-0.1.2 spec/elasticsearch_autocomplete/word_mode_spec.rb
elasticsearch_autocomplete-0.1.1 spec/elasticsearch_autocomplete/word_mode_spec.rb
elasticsearch_autocomplete-0.1.0 spec/elasticsearch_autocomplete/word_mode_spec.rb
elasticsearch_autocomplete-0.0.4 spec/elasticsearch_autocomplete/word_mode_spec.rb
elasticsearch_autocomplete-0.0.3 spec/elasticsearch_autocomplete/word_mode_spec.rb
elasticsearch_autocomplete-0.0.2 spec/elasticsearch_autocomplete/word_mode_spec.rb
elasticsearch_autocomplete-0.0.1 spec/elasticsearch_autocomplete/word_mode_spec.rb