Sha256: 1c0d4ef77381e699cf900c896e3a391cada5c20f449410be609e7a50ddf6a367
Contents?: true
Size: 1.61 KB
Versions: 21
Compression:
Stored size: 1.61 KB
Contents
# frozen_string_literal: true describe Spotlight::FieldMetadata do subject { described_class.new(exhibit, repository, blacklight_config) } let(:exhibit) { FactoryBot.create(:exhibit) } let(:repository) { double } let(:blacklight_config) do Blacklight::Configuration.new do |config| config.add_facet_field 'a' config.add_facet_field 'b' config.add_facet_field 'some_key', field: 'c' end end let(:facet_response) do { facet_counts: { facet_fields: { a: { 'a' => 1, 'b' => 2, 'c' => 3 }, b: { 'b' => 1 }, c: { 7 => 1, 8 => 2, 9 => 3 } }, facet_queries: { 'a:[* TO *]' => 5, 'b:[* TO *]' => 10, 'c:[* TO *]' => 15 } } }.with_indifferent_access end before do allow(repository).to receive(:search).with(an_instance_of(SearchBuilder)).and_return(Blacklight::Solr::Response.new(facet_response, {})) end describe '#field' do it 'has a document count' do expect(subject.field('a')[:document_count]).to eq 5 expect(subject.field('b')[:document_count]).to eq 10 expect(subject.field('some_key')[:document_count]).to eq 15 end it 'has a value count' do expect(subject.field('a')[:value_count]).to eq 3 expect(subject.field('b')[:value_count]).to eq 1 expect(subject.field('some_key')[:value_count]).to eq 3 end context 'for a missing field' do it 'has reasonable default values' do expect(subject.field('d')[:document_count]).to eq 0 expect(subject.field('d')[:value_count]).to eq 0 end end end end
Version data entries
21 entries across 21 versions & 1 rubygems