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