Sha256: 91dde30d4e68930f87b4f83f69c31744c944d8dae9ea0161fb37082ac2398162

Contents?: true

Size: 627 Bytes

Versions: 2

Compression:

Stored size: 627 Bytes

Contents

# frozen_string_literal: true

require 'test_helper'

require 'ostruct'

class HashTest < ActiveSupport::TestCase
  test 'to_deep_ostruct works' do
    hash = {
      first_level: {
        second_level: {
          second: 2
        },
        first:        1
      },
      top:         0
    }

    ostruct = hash.to_deep_ostruct

    assert ostruct.is_a? OpenStruct
    assert_equal 0, ostruct.top
    assert ostruct.first_level.is_a? OpenStruct
    assert_equal 1, ostruct.first_level.first
    assert ostruct.first_level.second_level.is_a? OpenStruct
    assert_equal 2, ostruct.first_level.second_level.second
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omu-support-0.1.2 test/core_ext/hash_test.rb
omu-support-0.1.1 test/core_ext/hash_test.rb