Sha256: 8c8275870a1154b820c3477f3ed0975f3a71c9fa74f0219535cc86aa1e3ac3b5

Contents?: true

Size: 542 Bytes

Versions: 2

Compression:

Stored size: 542 Bytes

Contents

require "test_helper"

class ObjectTest < Minitest::Test
  def test_creating_object_from_hash
    assert_equal "bar", Vultr::Object.new(foo: "bar").foo
  end

  def test_nested_hash
    assert_equal "foobar", Vultr::Object.new(foo: {bar: {baz: "foobar"}}).foo.bar.baz
  end

  def test_nested_number
    assert_equal 1, Vultr::Object.new(foo: {bar: 1}).foo.bar
  end

  def test_array
    object = Vultr::Object.new(foo: [{bar: :baz}])
    assert_equal OpenStruct, object.foo.first.class
    assert_equal :baz, object.foo.first.bar
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vultr-2.0.0 test/vultr/object_test.rb
vultr-1.0.0 test/vultr/object_test.rb