Sha256: fbcf86c3cbbf84d421d9c6c043094dca54f4d32538a01b984bce5d688f4697ec

Contents?: true

Size: 1.61 KB

Versions: 16

Compression:

Stored size: 1.61 KB

Contents

require './spec/spec_helper'

describe AccountReport do

  it_behaves_like(:account, AccountReport)

  let(:account_report) { 
    AccountReport.new({
      "Id" => "12345",
      "Name" => "Agent McAgentson",
      "Office" => "Office Name",
      "Emails"=>  [],
      "Phones"=>  [],
      "Websites"=>  [],
      "Addresses"=>  []
    }) 
  }

  describe 'primary_email' do

    it 'returns the primary email address' do
      account_report.emails << double(:Address => 'foo@foo.com', :primary? => true)
      expect(account_report.primary_email).to eq account_report.emails.primary.Address
    end

    it 'returns nil when there is no primary email address' do
      account_report.emails << double(:Address => 'foo@foo.com', :primary? => false)
      expect(account_report.primary_email).to eq nil
    end

    it 'returns nil when there are no email addresses' do
      allow(account_report).to receive(:emails).and_return nil
      expect(account_report.primary_email).to eq nil
    end
    
  end

  describe 'primary_phone' do

    it 'returns the primary phone number' do
      account_report.phones << double(:Number => '88', :primary? => true)
      expect(account_report.primary_phone).to eq account_report.phones.primary.Number
    end

    it 'returns nil when there is no primary phone number' do
      account_report.phones << double(:Number => '88', :primary? => false)
      expect(account_report.primary_phone).to eq nil
    end

    it 'returns nil when there are no phone numbers' do
      allow(account_report).to receive(:phones).and_return nil
      expect(account_report.primary_phone).to eq nil
    end
    
  end
  
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
spark_api-1.6.3 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.6.2 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.6.1 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.5.7 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.6.0 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.5.6 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.5.5 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.5.4 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.5.3 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.5.2 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.5.1 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.5.0 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.4.34 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.4.32 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.4.31 spec/unit/spark_api/models/account_report_spec.rb
spark_api-1.4.29 spec/unit/spark_api/models/account_report_spec.rb