Sha256: 5c48e85558a1fdc0a1ae9d1970f39bca2422c26f69a826f20551f4cbc6011271

Contents?: true

Size: 1.68 KB

Versions: 16

Compression:

Stored size: 1.68 KB

Contents

require_relative './spec_helper'

describe Groovy::Model, 'searching' do

  before :all do
    Groovy.open('tmp/search', 'search_spec')
    load_schema! 'search_spec'

    TestProduct.add_column :description, :string, index: true

    TestProduct.create!(name: 'First product', description: 'Lorem ipsum dolor sit amet')
    TestProduct.create!(name: 'Second product', description: 'Lorea el ipsum poh loco')
  end

  after :all do
    Groovy.close('search_spec')
  end

  describe 'single word, exact match' do
    it 'returns results' do
      # res = TestProduct.search(description: 'sit')
      res = TestProduct.search(description: 'sit')
      expect(res.first.name).to eq('First product')

      # res = TestProduct.search(description: 'loco')
      res = TestProduct.search(description: 'loco')
      expect(res.first.name).to eq('Second product')
    end
  end

  describe 'two consecutive words, exact match' do
    it 'returns results' do
      # res = TestProduct.search(description: 'sit amet')
      res = TestProduct.search(description: 'sit amet')
      expect(res.first.name).to eq('First product')

      # res = TestProduct.search(description: 'lorea el')
      res = TestProduct.search(description: 'lorea el')
      expect(res.first.name).to eq('Second product')
    end
  end

  describe 'two random words, both match' do
    it 'returns results' do
      # res = TestProduct.search(description: 'amet ipsum')
      res = TestProduct.search(description: 'amet ipsum')
      expect(res.first.name).to eq('First product')

      # res = TestProduct.search(description: 'poh el')
      res = TestProduct.search(description: 'poh el')
      expect(res.first.name).to eq('Second product')
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
groovy-0.6.8 spec/search_spec.rb
groovy-0.6.7 spec/search_spec.rb
groovy-0.6.6 spec/search_spec.rb
groovy-0.6.4 spec/search_spec.rb
groovy-0.6.1 spec/search_spec.rb
groovy-0.6.0 spec/search_spec.rb
groovy-0.5.1 spec/search_spec.rb
groovy-0.5.0 spec/search_spec.rb
groovy-0.4.7 spec/search_spec.rb
groovy-0.4.6 spec/search_spec.rb
groovy-0.4.5 spec/search_spec.rb
groovy-0.4.4 spec/search_spec.rb
groovy-0.4.3 spec/search_spec.rb
groovy-0.4.2 spec/search_spec.rb
groovy-0.4.1 spec/search_spec.rb
groovy-0.4.0 spec/search_spec.rb