Sha256: 1f2e2681f911a29b454c31379d0aab0b00faf3d0e7c3408545fc591b91f5678e
Contents?: true
Size: 1.4 KB
Versions: 4
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true RSpec.describe SolrDocument, api: true do describe "access methods" do let(:solrdoc) do SolrDocument.new(id: '00282214', format: ['Book'], title_tsim: 'some-title') end describe "#[]" do subject { solrdoc[field] } context "with title_tsim" do let(:field) { :title_tsim } it { is_expected.to eq 'some-title' } end context "with format" do let(:field) { :format } it { is_expected.to eq ['Book'] } end end describe "#id" do subject { solrdoc.id } it { is_expected.to eq '00282214' } end end describe '.attribute' do subject(:title) { document.title } let(:doc_class) do Class.new(SolrDocument) do attribute :title, Blacklight::Types::String, 'title_tesim' attribute :author, Blacklight::Types::Array, 'author_tesim' attribute :date, Blacklight::Types::Date, 'date_dtsi' end end let(:document) do doc_class.new(id: '123', title_tesim: ['Good Omens'], author_tesim: ['Neil Gaiman', 'Terry Pratchett'], date_dtsi: '1990-01-01T00:00:00Z') end it "casts the attributes" do expect(document.title).to eq 'Good Omens' expect(document.author).to eq ['Neil Gaiman', 'Terry Pratchett'] expect(document.date).to eq Date.new(1990) end end end
Version data entries
4 entries across 4 versions & 1 rubygems