Sha256: 286b348631d25d7b1d2a615af22a222ebf7bf9f25d3019e9ecacbdb6090214ff

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

RSpec.describe SearchyJson::Service do
  let!(:data_path) { File.join(File.dirname(__FILE__), '../../spec/fixtures/data.json') }
  let!(:primary_key) { 'Name' }
  let!(:search_fields) { ['Name', 'Type', 'Designed by'] }

  subject { SearchyJson::Service.new(data_path: data_path, primary_key: primary_key, search_fields: search_fields) }

  describe '#find' do
    context 'Support reverse keywords' do
      it 'finds two languages' do
        result = subject.find('Lisp Common')

        expect(result).to match_array(['Common Lisp', 'Lisp'])
      end
    end

    context 'Support exacts matching' do
      it 'finds one language' do
        result = subject.find('"Thomas Eugene"')

        expect(result).to eq(['BASIC'])
      end
    end

    context 'Support negative searching' do
      it 'finds result' do
        result = subject.find('"Thomas Eugene"')

        expect(result).to eq(['BASIC'])
      end
    end

    # context 'Support different fields' do
    #   it 'finds result' do
    #     result = subject.find('"Thomas Eugene"')

    #     expect(result).to eq(['BASIC'])
    #   end
    # end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
searchy-json-0.3.1 spec/searchy/service_spec.rb
searchy-json-0.3.0 spec/searchy/service_spec.rb