Sha256: db07e4384ac504a68a3a2db34262f07cef0af968ceebe18b3a5d21ea33a952ed
Contents?: true
Size: 1.29 KB
Versions: 5
Compression:
Stored size: 1.29 KB
Contents
require File.expand_path('../test_helper', __FILE__) module Loquor class ObjectHashTest < Minitest::Test def test_is_accessible_as_a_hash representation = ObjectHash.new({foo: "bar"}) assert_equal "bar", representation[:foo] end def test_hash_symbol_keys_are_accessible_as_strings representation = ObjectHash.new({foo: "bar"}) assert_equal "bar", representation["foo"] end def test_hash_string_keys_are_accessible_as_symbols representation = ObjectHash.new({"foo" => "bar"}) assert_equal "bar", representation[:foo] end def test_hash_keys_are_accessible_as_orignals representation = ObjectHash.new({1 => "bar"}) assert_equal "bar", representation[1] end def test_hash_keys_are_accessible_via_methods representation = ObjectHash.new({foo: "bar"}) assert_equal "bar", representation.foo end def test_non_strict_returns_nil_on_missing_attribute representation = ObjectHash.new({foo: "bar"}) assert_equal nil, representation.cat end def test_strict_raises_on_missing_attribute representation = ObjectHash.new({foo: "bar"}, strict: true) ex = assert_raises(ObjectHashKeyMissingError) do representation.cat end assert_equal "cat", ex.message end end end
Version data entries
5 entries across 5 versions & 1 rubygems