Sha256: f6b1e5eaf3cb1b89e70cdfb94905faa86a792a111c6a0902b189fe121277e0b0

Contents?: true

Size: 837 Bytes

Versions: 4

Compression:

Stored size: 837 Bytes

Contents

require 'spec_helper'

describe SearchKit::Models::Document do
  let(:document_data) { {} }
  let(:document) { described_class.new(document_data) }

  subject { document }

  it { is_expected.to respond_to :id }
  it { is_expected.to respond_to :source }
  it { is_expected.to respond_to :score }

  describe '#get' do
    let(:key) { :a_key }

    subject { document.get(key) }

    context 'when the source has the available content' do
      let(:content)       { :key_content }
      let(:document_data) { { attributes: { key => content } } }

      it "returns the content" do
        expect(subject).to eq content
      end
    end

    context 'otherwise' do
      it "raises an attribute not found error" do
        expect { subject }
          .to raise_exception(described_class::AttributeNotFound)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
search-kit-0.0.7 spec/search_kit/models/document_spec.rb
search-kit-0.0.6 spec/search_kit/models/document_spec.rb
search-kit-0.0.5 spec/search_kit/models/document_spec.rb
search-kit-0.0.4 spec/search_kit/models/document_spec.rb