test/telnyx/telnyx_object_test.rb in telnyx-2.6.0 vs test/telnyx/telnyx_object_test.rb in telnyx-2.7.0
- old
+ new
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require ::File.expand_path("../../test_helper", __FILE__)
+require_relative "../test_helper"
module Telnyx
class TelnyxObjectTest < Test::Unit::TestCase
should "implement #==" do
obj1 = Telnyx::TelnyxObject.construct_from(id: 1, foo: "bar")
@@ -157,24 +157,22 @@
end
end
context "#to_hash" do
should "skip calling to_hash on nil" do
- begin
- module NilWithToHash
- def to_hash
- raise "Can't call to_hash on nil"
- end
+ module NilWithToHash
+ def to_hash
+ raise "Can't call to_hash on nil"
end
- ::NilClass.include NilWithToHash
-
- hash_with_nil = { id: 3, foo: nil }
- obj = TelnyxObject.construct_from(hash_with_nil)
- expected_hash = { id: 3, foo: nil }
- assert_equal expected_hash, obj.to_hash
- ensure
- ::NilClass.send(:undef_method, :to_hash)
end
+ ::NilClass.include NilWithToHash
+
+ hash_with_nil = { id: 3, foo: nil }
+ obj = TelnyxObject.construct_from(hash_with_nil)
+ expected_hash = { id: 3, foo: nil }
+ assert_equal expected_hash, obj.to_hash
+ ensure
+ ::NilClass.send(:undef_method, :to_hash)
end
should "recursively call to_hash on its values" do
# deep nested hash (when contained in an array) or TelnyxObject
nested_hash = { id: 7, foo: "bar" }