Sha256: bac52f5f189170a1bab8c5a719d5ca9f2050cbb8fe8c82b76441bf197373da53

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

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

describe Pupa::Concerns::Contactable do
  let :klass do
    Class.new(Pupa::Base) do
      include Pupa::Concerns::Contactable
    end
  end

  let :object do
    klass.new
  end

  describe '#contact_details=' do
    it 'should use coerce to a ContactDetailList' do
      object.contact_details = [{type: 'email', value: 'ceo@example.com', note: 'work'}]
      object.contact_details.should be_a(Pupa::ContactDetailList)
    end
  end

  describe '#add_contact_detail' do
    it 'should add a contact detail' do
      object.add_contact_detail('email', 'ceo@example.com', note: 'work')
      object.contact_details.should == [{type: 'email', value: 'ceo@example.com', note: 'work'}]
    end

    it 'should not add a contact detail without a type' do
      object.add_contact_detail('email', nil)
      object.contact_details.blank?.should == true
    end

    it 'should not add a contact detail without a value' do
      object.add_contact_detail(nil, 'ceo@example.com')
      object.contact_details.blank?.should == true
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pupa-0.0.8 spec/models/concerns/contactable_spec.rb
pupa-0.0.7 spec/models/concerns/contactable_spec.rb
pupa-0.0.6 spec/models/concerns/contactable_spec.rb
pupa-0.0.5 spec/models/concerns/contactable_spec.rb
pupa-0.0.4 spec/models/concerns/contactable_spec.rb
pupa-0.0.3 spec/models/concerns/contactable_spec.rb
pupa-0.0.2 spec/models/concerns/contactable_spec.rb
pupa-0.0.1 spec/models/concerns/contactable_spec.rb