Sha256: df58a0b511e2faf924413e8513f0b2414ce043b02b5326b5166f07ee1e803bb6

Contents?: true

Size: 1.03 KB

Versions: 74

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

RSpec.describe 'Blacklight::Document::ActiveModelShim', api: true do
  class MockDocument
    include Blacklight::Document
    include Blacklight::Document::ActiveModelShim
  end

  class MockResponse
    attr_reader :response, :params

    def initialize(response, params)
      @response = response
      @params = params
    end

    def documents
      response.collect { |doc| MockDocument.new(doc, self) }
    end
  end

  before do
    allow(MockDocument).to receive(:repository).and_return(double(find: MockResponse.new([{ id: 1 }], {})))
  end

  describe "#find" do
    it "returns a document from the repository" do
      expect(MockDocument.find(1)).to be_a MockDocument
      expect(MockDocument.find(1).id).to be 1
    end
  end

  describe "#==" do
    it 'is equal for the same id' do
      expect(MockDocument.new(id: 1) == MockDocument.new(id: 1)).to eq true
    end

    it 'is not equal if the ids differ' do
      expect(MockDocument.new(id: 1) == MockDocument.new(id: 2)).to eq false
    end
  end
end

Version data entries

74 entries across 74 versions & 2 rubygems

Version Path
blacklight-7.18.0 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.17.2 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.17.1 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.17.0 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.16.0 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.15.2 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.15.1 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.15.0 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.14.1 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.14.0 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.13.2 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.13.1 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.13.0 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.12.1 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.12.0 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.11.1 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.10.0 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.9.0 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.8.1 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-7.8.0 spec/models/blacklight/document/active_model_shim_spec.rb