Module: Hash::EasyAccess::Etest
- Defined in:
- lib/vex/base/hash/easy_access.rb
Instance Method Summary collapse
- #test_easy_access_assigns ⇒ Object
- #test_easy_access_hashes ⇒ Object
- #test_easy_access_hashes_2 ⇒ Object
Instance Method Details
#test_easy_access_assigns ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/vex/base/hash/easy_access.rb', line 122 def test_easy_access_assigns h = { :a => { "b" => "ccc" }} h.easy_access! h.a = 2 assert_equal({ :a => 2}, h) h.b = 2 assert_equal({ :a => 2, "b" => 2}, h) v = { :c => { :d => 2 } } assert !v.easy_accessible? h.b = v assert_equal(2, h.b.c.d) assert !v.easy_accessible? assert h.b.easy_accessible? end |
#test_easy_access_hashes ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/vex/base/hash/easy_access.rb', line 92 def test_easy_access_hashes h = { :a => { "b" => "ccc" }} h1 = h.easy_access! assert h.easy_accessible? assert h1.easy_accessible? assert_equal("ccc", h.a.b) assert h1.object_id == h.object_id assert h.a? assert !h.b? assert h.a.b? assert !h.a.c? end |
#test_easy_access_hashes_2 ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/vex/base/hash/easy_access.rb', line 107 def test_easy_access_hashes_2 h = { :a => { "b" => "ccc" }} h1 = h.easy_access assert !h.easy_accessible? assert h1.easy_accessible? assert_equal("ccc", h1.a.b) assert h1.object_id != h.object_id assert h1.a? assert !h1.b? assert h1.a.b? assert !h1.a.c? end |