Sha256: 206e0079e3b8786fa4976b999506529d3724e91db51e8e606d1da81b91ccca47

Contents?: true

Size: 916 Bytes

Versions: 4

Compression:

Stored size: 916 Bytes

Contents

require 'spec_helper'

describe Intercom::Company do
  
  describe 'when no response raises error' do
    it 'on find' do
      Intercom.expects(:get).with("/companies", {:company_id => '4'}).returns(nil)
      proc {company = Intercom::Company.find(:company_id => '4')}.must_raise Intercom::HttpError
    end
    
    it 'on find_all' do
      Intercom.expects(:get).with("/companies", {}).returns(nil)
      proc {Intercom::Company.all.each {|company| }}.must_raise Intercom::HttpError
    end
    
    it 'on load' do
      Intercom.expects(:get).with("/companies", {:company_id => '4'}).returns({'type' =>'user', 'id' =>'aaaaaaaaaaaaaaaaaaaaaaaa', 'company_id' => '4', 'name' => 'MyCo'})
      company = Intercom::Company.find(:company_id => '4')
      Intercom.expects(:get).with('/companies/aaaaaaaaaaaaaaaaaaaaaaaa', {}).returns(nil)
      proc {company.load}.must_raise Intercom::HttpError
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
intercom-2.4.2 spec/unit/intercom/company_spec.rb
intercom-2.4.1 spec/unit/intercom/company_spec.rb
intercom-2.4.0 spec/unit/intercom/company_spec.rb
intercom-2.3.0 spec/unit/intercom/company_spec.rb