Sha256: bb6ae15cfbb0b0a8e3384b58422a49597a9fb40a8359e6f234e040f4eb0ade00

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

require 'sitehub/collection'

class SiteHub
  describe Collection do
    describe '#valid?' do
      it 'must be overiden and raises an exception by default' do
        expect { subject.valid? }.to raise_exception 'implement me'
      end
    end

    describe '#resolve' do
      it 'must be overiden and raises an exception by default' do
        expect { subject.resolve }.to raise_exception 'implement me'
      end
    end

    describe '.inherited' do
      describe '#add' do
        context 'duplicate ids added' do
          subject do
            inheritor = Class.new(described_class) do
              def add(id, value, *_args)
                self[id] = value
              end
            end

            inheritor.new
          end

          it 'raises an error' do
            duplicate = Struct.new(:id).new(1)
            subject.add(duplicate.id, duplicate)
            expected_message = described_class::ClassMethods::UNIQUE_LABELS_MSG
            expect { subject.add(duplicate.id, duplicate) }
              .to raise_exception described_class::DuplicateVersionError, expected_message
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sitehub-0.5.0.alpha12 spec/sitehub/collection_spec.rb
sitehub-0.5.0.alpha11 spec/sitehub/collection_spec.rb
sitehub-0.5.0.alpha10 spec/sitehub/collection_spec.rb
sitehub-0.5.0.alpha8 spec/sitehub/collection_spec.rb