Sha256: e1704788183176234c0d82324a6389a64bd6980b10accd7f8650113f673bd0fb

Contents?: true

Size: 1.49 KB

Versions: 15

Compression:

Stored size: 1.49 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe Pupa::Concerns::Identifiable do
  let :klass do
    Class.new do
      include Pupa::Model
      include Pupa::Concerns::Identifiable
    end
  end

  let :object do
    klass.new
  end

  describe '#initialize' do
    it 'should initialize an empty IdentifierList' do
      object.identifiers.should be_a(Pupa::IdentifierList)
      object.identifiers.should == []
    end

    it 'should initialize the given IdentifierList' do
      object = klass.new(identifiers: [{identifier: '123456789', scheme: 'DUNS'}])
      object.identifiers.should == [{identifier: '123456789', scheme: 'DUNS'}]
    end
  end

  describe '#identifiers=' do
    it 'should use coerce to a IdentifierList' do
      object.identifiers = [{identifier: '123456789', scheme: 'DUNS'}]
      object.identifiers.should be_a(Pupa::IdentifierList)
    end

    it 'should symbolize keys' do
      object.identifiers = [{'identifier' => '123456789', 'scheme' => 'DUNS'}]
      object.identifiers.should == [{identifier: '123456789', scheme: 'DUNS'}]
    end
  end

  describe '#add_identifier' do
    it 'should add an identifier' do
      object.add_identifier('123456789', scheme: 'duns')
      object.identifiers.should == [{identifier: '123456789', scheme: 'duns'}]
    end

    it 'should not add an identifier without an identifier' do
      object.add_identifier(nil)
      object.add_identifier('')
      object.identifiers.blank?.should == true
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pupa-0.1.11 spec/models/concerns/identifiable_spec.rb
pupa-0.1.10 spec/models/concerns/identifiable_spec.rb
pupa-0.1.9 spec/models/concerns/identifiable_spec.rb
pupa-0.1.8 spec/models/concerns/identifiable_spec.rb
pupa-0.1.7 spec/models/concerns/identifiable_spec.rb
pupa-0.1.6 spec/models/concerns/identifiable_spec.rb
pupa-0.1.5 spec/models/concerns/identifiable_spec.rb
pupa-0.1.4 spec/models/concerns/identifiable_spec.rb
pupa-0.1.3 spec/models/concerns/identifiable_spec.rb
pupa-0.1.2 spec/models/concerns/identifiable_spec.rb
pupa-0.1.1 spec/models/concerns/identifiable_spec.rb
pupa-0.1.0 spec/models/concerns/identifiable_spec.rb
pupa-0.0.13 spec/models/concerns/identifiable_spec.rb
pupa-0.0.12 spec/models/concerns/identifiable_spec.rb
pupa-0.0.11 spec/models/concerns/identifiable_spec.rb