Sha256: 90bd76005f9f1392590c1d9360589b4a930ca159193747b08862bf78abe89eab

Contents?: true

Size: 1.37 KB

Versions: 6

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require ::File.expand_path("../../test_helper", __FILE__)

module Telnyx
  class TelnyxErrorTest < Test::Unit::TestCase
    context "#to_s" do
      should "convert to string" do
        e = TelnyxError.new([{ "title" => "Missing required attributes" }])
        assert_equal 'Missing required attributes Full details: [{"title"=>"Missing required attributes"}]', e.to_s

        e = TelnyxError.new([{ "title" => "Missing required attributes" }], http_status: 422)
        assert_equal '(Status 422) Missing required attributes Full details: [{"title"=>"Missing required attributes"}]', e.to_s

        e = TelnyxError.new([{ "title" => "Missing required attributes" }], http_status: nil, http_body: nil, json_body: nil, http_headers: { request_id: "request-id" })
        assert_equal '(Request request-id) Missing required attributes Full details: [{"title"=>"Missing required attributes"}]', e.to_s

        e = TelnyxError.new([{ "title" => "Missing required attributes" }, { "title" => "Phone number must be in +E.164 format" }], http_status: nil, http_body: nil, json_body: nil, http_headers: { request_id: "request-id" })
        assert_equal '(Request request-id) Missing required attributes plus 1 other error. Full details: [{"title"=>"Missing required attributes"}, {"title"=>"Phone number must be in +E.164 format"}]', e.to_s
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
telnyx-2.6.0 test/telnyx/errors_test.rb
telnyx-2.5.0 test/telnyx/errors_test.rb
telnyx-2.4.0 test/telnyx/errors_test.rb
telnyx-2.3.0 test/telnyx/errors_test.rb
telnyx-2.2.0 test/telnyx/errors_test.rb
telnyx-0.1.0 test/telnyx/errors_test.rb