Sha256: cf9a8c921770d83ee944c8362fc7eca966472fb599144b25b43f6b6b2fb38d8f

Contents?: true

Size: 786 Bytes

Versions: 3

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true
require 'spec_helper'

describe 'Blacklight::Document::ActiveModelShim' 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 "should return a document from the repository" do
      expect(MockDocument.find(1)).to be_a MockDocument
      expect(MockDocument.find(1).id).to be 1
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-6.3.1 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-6.3.0 spec/models/blacklight/document/active_model_shim_spec.rb
blacklight-6.2.0 spec/models/blacklight/document/active_model_shim_spec.rb