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.23.0.1 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.23.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.22.2 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.22.1 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.22.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.21.2 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.21.1 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.21.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.20.1 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.20.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.19.2 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.19.1 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.19.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.18.1 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.18.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.17.2 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.17.1 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.17.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.16.0 spec/models/blacklight/suggest/response_spec.rb
blacklight-7.15.2 spec/models/blacklight/suggest/response_spec.rb