Module: Hash::SimpleAccessMethods::Etest
- Defined in:
- lib/vex/base/hash/simple_access_methods.rb
Instance Method Summary collapse
- #test_assignments ⇒ Object
- #test_missing_methods ⇒ Object
- #test_respond_to ⇒ Object
- #test_simple_access ⇒ Object
- #test_simple_access_deep ⇒ Object
Instance Method Details
#test_assignments ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/vex/base/hash/simple_access_methods.rb', line 31 def test_assignments h = { :a => "aa", :b => "bb", "c" => "cc" } Deprecation.quiet do h.with_simple_access end h.a = 2 assert_equal(2, h.a) end |
#test_missing_methods ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/vex/base/hash/simple_access_methods.rb', line 22 def test_missing_methods h = { :a => "aa", :b => "bb", "c" => "cc" } Deprecation.quiet do h.with_simple_access end assert_raise(NoMethodError) { h.x } assert_raise(NoMethodError) { h.a(1) } end |
#test_respond_to ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/vex/base/hash/simple_access_methods.rb', line 41 def test_respond_to h = { :a => "aa", :b => "bb", "c" => "cc" } Deprecation.quiet do h.with_simple_access end assert(h.respond_to?(:a)) assert(h.respond_to?(:b)) assert(h.respond_to?(:c)) assert(h.respond_to?(:"a=")) assert(h.respond_to?("a=")) assert(h.respond_to?("a")) assert(h.respond_to?("c=")) assert(h.respond_to?("c")) # inherited methods assert(h.respond_to?("keys")) # inherited methods assert(!h.respond_to?("unknown_key")) assert(!h.respond_to?("unknown_key=")) end |
#test_simple_access ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/vex/base/hash/simple_access_methods.rb', line 11 def test_simple_access h = { :a => "aa", :b => "bb", "c" => "cc" } Deprecation.quiet do h.with_simple_access end assert_equal("aa", h.a) assert_equal("bb", h.b) assert_equal("cc", h.c) end |
#test_simple_access_deep ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/vex/base/hash/simple_access_methods.rb', line 66 def test_simple_access_deep h = { :a => { :b => "bb" } } Deprecation.quiet do h.with_simple_access end assert_equal("bb", h.a.b) end |