Class: Ccp::Utils::TestFailed::Differ
- Inherits:
-
Struct
- Object
- Struct
- Ccp::Utils::TestFailed::Differ
- Defined in:
- lib/ccp/utils/test_failed.rb,
lib/ccp/utils/test_failed.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#b ⇒ Object
Returns the value of attribute b.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a
4 5 6 |
# File 'lib/ccp/utils/test_failed.rb', line 4 def a @a end |
#b ⇒ Object
Returns the value of attribute b
4 5 6 |
# File 'lib/ccp/utils/test_failed.rb', line 4 def b @b end |
#path ⇒ Object
Returns the value of attribute path
4 5 6 |
# File 'lib/ccp/utils/test_failed.rb', line 4 def path @path end |
Instance Method Details
#execute ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ccp/utils/test_failed.rb', line 6 def execute unless a.class == b.class failed("%s expected [%s], but got [%s]" % [path, a.class, b.class]) end if a.class == Array max = [a.size, b.size].max (0...max).each do |i| Differ.new(a[i], b[i], "#{path}[#{i}]").execute end return true end if a.class == Hash (a.keys | b.keys).each do |key| Differ.new(a[key], b[key], "#{path}[#{key}]").execute end return true end unless a == b failed("%s expected %s, but got %s" % [path, a.inspect, b.inspect]) end end |