Class: Hash

Inherits:
Object show all
Defined in:
lib/web/assertinclude.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#__index(key) ⇒ Object



84
85
86
# File 'lib/web/assertinclude.rb', line 84

def __index(key)
  self[key]
end

#assert_includes(needle, message = "") ⇒ Object



105
106
107
108
109
110
111
# File 'lib/web/assertinclude.rb', line 105

def assert_includes( needle, message="" )
  message = needle.compare_includes? self
  unless message == ""
    raise Test::Unit::AssertionFailedError.new(message)
    #flunk( message )
  end
end

#compare_includes?(haystack, prefix = []) ⇒ Boolean

Returns:

  • (Boolean)


88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/web/assertinclude.rb', line 88

def compare_includes? haystack, prefix=[]
  message = ""
  # check that haystack is the same type?
  
  # iterate over your self (particular to self)
  self.each do |k,v|
    
   # make a sensible name for each element of the needle (particular to self)
   fullname = prefix.clone.push k
   fullname_str = fullname.join(".")
   
   message += do_thing(haystack, k, v, fullname, fullname_str)
  end
  
  message
end