Sha256: 2ddf70ea242ab5b2888671734ea4e53e095cc27dec8a52bf2bbba4daaf9fcb09

Contents?: true

Size: 810 Bytes

Versions: 4

Compression:

Stored size: 810 Bytes

Contents

require 'spec_helper'
require 'ostruct'

describe 'Intercom::Request' do
  it 'raises an error when a html error page rendered' do
    response = OpenStruct.new(:code => 500)
    req = Intercom::Request.new('path/', 'GET')
    proc {req.parse_body('<html>somethjing</html>', response)}.must_raise(Intercom::ServerError)
  end

  it 'raises a RateLimitExceeded error when the response code is 429' do
    response = OpenStruct.new(:code => 429)
    req = Intercom::Request.new('path/', 'GET')
    proc {req.parse_body('<html>somethjing</html>', response)}.must_raise(Intercom::RateLimitExceeded)
  end

  it 'parse_body returns nil if decoded_body is nil' do
    response = OpenStruct.new(:code => 500)
    req = Intercom::Request.new('path/', 'GET')
    req.parse_body(nil, response).must_equal(nil)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
intercom-3.5.17 spec/unit/intercom/request_spec.rb
intercom-3.5.16 spec/unit/intercom/request_spec.rb
intercom-3.5.15 spec/unit/intercom/request_spec.rb
intercom-3.5.14 spec/unit/intercom/request_spec.rb