Sha256: 26863a95f53fe18cf095ceb19dc11565b964e922db54d38eba943ebf4e22b23c

Contents?: true

Size: 1.3 KB

Versions: 8

Compression:

Stored size: 1.3 KB

Contents

require 'spec_helper'

describe CurationConcern::CollectionModel do
  let(:klass) {
    Class.new(ActiveFedora::Base) {
      include CurationConcern::CollectionModel
      def members; @members ||= []; end
      def save; true; end
    }
  }

  context '.add_member' do
    let(:collectible?) { nil }
    let(:proposed_collectible) { double(collections: []) }
    subject { klass.new }
    before(:each) {
      proposed_collectible.stub(:can_be_member_of_collection?).with(subject).and_return(collectible?)
      proposed_collectible.stub(:save).and_return(true)
    }

    context 'with itself' do
      it 'does not add it to the collection\'s members' do
        expect {
          subject.add_member(subject)
        }.to_not change{ subject.members.size }
      end
    end

    context 'with a non-collectible object' do
      let(:collectible?) { false }
      it 'does not add it to the collection\'s members' do
        expect {
          subject.add_member(proposed_collectible)
        }.to_not change{ subject.members.size }
      end
    end

    context 'with a collectible object' do
      let(:collectible?) { true }
      it 'adds it to the collection\'s members' do
        expect {
          subject.add_member(proposed_collectible)
        }.to change{ subject.members.size }.by(1)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
curate-0.6.6 spec/repository_models/curation_concern/collection_model_spec.rb
curate-0.6.5 spec/repository_models/curation_concern/collection_model_spec.rb
curate-0.6.4 spec/repository_models/curation_concern/collection_model_spec.rb
curate-0.6.3 spec/repository_models/curation_concern/collection_model_spec.rb
curate-0.6.1 spec/repository_models/curation_concern/collection_model_spec.rb
curate-0.6.0 spec/repository_models/curation_concern/collection_model_spec.rb
curate-0.5.6 spec/repository_models/curation_concern/collection_model_spec.rb
curate-0.5.5 spec/repository_models/curation_concern/collection_model_spec.rb