Sha256: ebb86cbd06fa6956ec7956dc5a36637374512f4a9f6f975029c3579fcd500715

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe CurationConcerns::CollectionPresenter do
  let(:collection) { Collection.new(id: 'adc12v', description: 'a nice collection', title: 'A clever title') }
  let(:work) { FactoryGirl.build(:work, title: ['unimaginitive title']) }
  let(:solr_document) { SolrDocument.new(collection.to_solr) }
  let(:ability) { double }
  let(:presenter) { described_class.new(solr_document, ability) }

  # Mock bytes so collection does not have to be saved.
  before { allow(collection).to receive(:bytes).and_return(0) }

  describe '#title' do
    subject { presenter.title }
    it { is_expected.to eq 'A clever title' }
  end

  describe '#to_key' do
    subject { presenter.to_key }
    it { is_expected.to eq ['adc12v'] }
  end

  describe "#size" do
    subject { presenter.size }
    it { is_expected.to eq '0 Bytes' }
  end

  describe "#total_items" do
    subject { presenter.total_items }
    context "empty collection" do
      it { is_expected.to eq 0 }
    end
    context "collection with work" do
      before { collection.members << work }
      it { is_expected.to eq 1 }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
curation_concerns-0.8.0 spec/presenters/curation_concerns/collection_presenter_spec.rb
curation_concerns-0.7.0 spec/presenters/curation_concerns/collection_presenter_spec.rb
curation_concerns-0.6.0 spec/presenters/curation_concerns/collection_presenter_spec.rb
curation_concerns-0.5.0 spec/presenters/curation_concerns/collection_presenter_spec.rb
curation_concerns-0.4.0 spec/presenters/curation_concerns/collection_presenter_spec.rb