Sha256: 881f78f1d2df86d14a21d273be9fe081a0255affcd285db63449399179fb1e66
Contents?: true
Size: 1.6 KB
Versions: 35
Compression:
Stored size: 1.6 KB
Contents
require 'spec_helper' describe CurationConcerns::PresenterFactory do describe "#build_presenters" do let(:presenter_class) { CurationConcerns::FileSetPresenter } before do allow(ActiveFedora::SolrService.instance.conn).to receive(:post) .with('select', data: { q: "{!terms f=id}12,13", rows: 1000, qt: 'standard' }) .and_return('response' => { 'docs' => results }) end subject { described_class.build_presenters(['12', '13'], presenter_class, nil) } context "when some ids are found in solr" do let(:results) { [{ "id" => "12" }, { "id" => "13" }] } it "has two results" do expect(subject.size).to eq 2 end end context "when some ids are not found in solr" do let(:results) { [{ "id" => "13" }] } it "has one result" do expect(subject.size).to eq 1 end end context "with more arguments" do let(:presenter_class) do Class.new(CurationConcerns::FileSetPresenter) do attr_reader :two, :three def initialize(_one, two, three) @two = two @three = three end end end let(:results) { [{ "id" => "12" }, { "id" => "13" }] } subject { described_class.build_presenters(['12', '13'], presenter_class, 'more', 'and more') } it 'passes all the arguments' do expect(subject.first.two).to eq 'more' expect(subject.first.three).to eq 'and more' end end end end
Version data entries
35 entries across 35 versions & 1 rubygems