Sha256: 03016c990ff09a8f8dceac5c6d3b9eef6bb23bbbb09b581799f5953a88b21f8a

Contents?: true

Size: 1.45 KB

Versions: 84

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

RSpec.describe Blacklight::Suggest::Response, api: true do
  let(:empty_response) { described_class.new({}, { q: 'hello' }, 'suggest', 'mySuggester') }
  let(:full_response) do
    described_class.new(
      {
        'responseHeader' => {
          'status' => 200
        },
        'suggest' => {
          'mySuggester' => {
            'new' => {
              'numFound' => 3,
              'suggestions' => [
                {
                  'term' => 'new jersey',
                  'weight' => 3,
                  'payload' => ''
                },
                {
                  'term' => 'new jersey bridgeton biography',
                  'weight' => 3,
                  'payload' => ''
                },
                {
                  'term' => 'new jersey bridgeton history',
                  'weight' => 3,
                  'payload' => ''
                }
              ]
            }
          }
        }
      },
      {
        q: 'new'
      },
      'suggest',
      'mySuggester'
    )
  end

  describe '#initialize' do
    it 'creates a Blacklight::Suggest::Response' do
      expect(empty_response).to be_an described_class
    end
  end

  describe '#suggestions' do
    it 'returns an array of suggestions' do
      expect(full_response.suggestions).to be_an Array
      expect(full_response.suggestions.count).to eq 3
      expect(full_response.suggestions.first['term']).to eq 'new jersey'
    end
  end
end

Version data entries

84 entries across 84 versions & 2 rubygems

Version Path
blacklight-7.40.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.39.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.38.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/models/blacklight/suggest/response_spec.rb
blacklight-8.2.2 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.2.1 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.2.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.37.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.36.2 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.36.1 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.36.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.35.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.1.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.34.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.0.1 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.0.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.0.0.beta8 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.0.0.beta7 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.0.0.beta6 spec/models/blacklight/suggest/response_spec.rb
blacklight-8.0.0.beta5 spec/models/blacklight/suggest/response_spec.rb