Sha256: def779a14df74e7b3e1f22ff15ab975e2eed261a45bcc52e0f137f1e13fe732c
Contents?: true
Size: 1.03 KB
Versions: 7
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true RSpec.describe 'Blacklight::Document::ActiveModelShim', :api 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 be true end it 'is not equal if the ids differ' do expect(MockDocument.new(id: 1) == MockDocument.new(id: 2)).to be false end end end
Version data entries
7 entries across 7 versions & 2 rubygems