Sha256: dc2485eade58ddf010cad3e7953738ab86bbfac9adf6e561bba9be1107ffb85b

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'
require_relative '../../lib/PCP-server-Ruby-SDK.rb'

RSpec.describe PCPServerSDK::Errors::ApiResponseRetrievalException do
  before(:each) do
    @status_code = 500
    @response_body = "Internal Server Error"
    @cause = StandardError.new("Original error")
  end

  describe "#initialize" do
    it "sets attributes" do
      exception = PCPServerSDK::Errors::ApiResponseRetrievalException.new(@status_code, @response_body)
      expect(exception.status_code).to eq(@status_code)
      expect(exception.response_body).to eq(@response_body)
    end

    it "sets backtrace when initialized with cause" do
      @cause.set_backtrace(["line 1", "line 2"])
      exception = PCPServerSDK::Errors::ApiResponseRetrievalException.new(@status_code, @response_body, @cause)
      expect(exception.backtrace).to eq(@cause.backtrace)
    end
  end

  describe "inheritance" do
    it "inherits from ApiException" do
      exception = PCPServerSDK::Errors::ApiResponseRetrievalException.new(@status_code, @response_body)
      expect(exception).to be_kind_of(PCPServerSDK::Errors::ApiException)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pcp-server-ruby-sdk-1.0.0 spec/errors/api_response_retrieval_exception_spec.rb