Sha256: 79832acd588c6c54e118b07495c94ac69200362af9149b158b0c15a2b2b72a21

Contents?: true

Size: 967 Bytes

Versions: 21

Compression:

Stored size: 967 Bytes

Contents

require 'spec_helper'

describe Spotlight::ResourceProvider do
  describe '.for_resource' do
    let(:thing) { double }
    let(:type_a) { double('TypeA', weight: 10) }
    let(:type_b) { double('TypeB', weight: 5) }
    let(:providers) { [type_a, type_b] }
    subject { described_class.for_resource(thing) }

    before do
      allow(described_class).to receive_messages(providers: providers)
    end

    it 'returns a class that can provide indexing for the resource' do
      expect(type_a).to receive(:can_provide?).with(thing).and_return(true)
      expect(type_b).to receive(:can_provide?).with(thing).and_return(false)
      expect(subject).to eq type_a
    end

    it 'returns the lowest weighted class that can provide indexing for the resource' do
      expect(type_a).to receive(:can_provide?).with(thing).and_return(true)
      expect(type_b).to receive(:can_provide?).with(thing).and_return(true)
      expect(subject).to eq type_b
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
blacklight-spotlight-0.15.0 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.14.2 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.14.1 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.14.0 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.13.0 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.12.1 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.12.0 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.11.0 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.10.3 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.10.2 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.10.1 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.10.0 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.9.2 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.9.1 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.9.0 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.8.2 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.8.1 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.8.0 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.7.2 spec/models/spotlight/resource_provider_spec.rb
blacklight-spotlight-0.7.1 spec/models/spotlight/resource_provider_spec.rb