Sha256: 7db071cdb9fa93261c73bbe55e8df7f41a200ba7076503e775fb2c581ccca490

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

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

describe Pupa::ContactDetailList do
  let :object do
    Pupa::ContactDetailList.new([
      {
        type: 'address',
        value: 'first',
      },
      {
        type: 'address',
        value: 'second',
      },
      {
        type: 'email',
        value: 'first',
      },
      {
        type: 'email',
        value: 'second',
      },
      {
        type: 'custom',
        value: 'content',
      },
    ])
  end

  describe '#address' do
    it 'should return the first postal address' do
      expect(object.address).to eq('first')
    end

    it 'should return nil if no postal addresses' do
      expect(Pupa::ContactDetailList.new.address).to eq(nil)
    end
  end

  describe '#email' do
    it 'should return the first email address' do
      expect(object.email).to eq('first')
    end

    it 'should return nil if no email addresses' do
      expect(Pupa::ContactDetailList.new.email).to eq(nil)
    end
  end

  describe '#find_by_type' do
    it 'should return the value of the first contact detail matching the type' do
      expect(object.find_by_type('custom')).to eq('content')
    end

    it 'should return nil if no contact detail matches the type' do
      expect(Pupa::ContactDetailList.new.find_by_type('custom')).to eq(nil)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pupa-0.2.4 spec/models/contact_detail_list_spec.rb
pupa-0.2.3 spec/models/contact_detail_list_spec.rb
pupa-0.2.2 spec/models/contact_detail_list_spec.rb
pupa-0.2.1 spec/models/contact_detail_list_spec.rb
pupa-0.2.0 spec/models/contact_detail_list_spec.rb