Class: Maze::Compare::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/maze/compare.rb

Overview

Provides a way to delivering results of element comparisons to test steps

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResult

Creates the Result object



21
22
23
24
25
# File 'lib/maze/compare.rb', line 21

def initialize
  @equal = true
  @keys = []
  @reasons = []
end

Instance Attribute Details

#equal=(value) ⇒ Object (writeonly)

Sets the attribute equal

Parameters:

  • value

    the value to set the attribute equal to.



14
15
16
# File 'lib/maze/compare.rb', line 14

def equal=(value)
  @equal = value
end

#keysObject (readonly)

Returns the value of attribute keys.



18
19
20
# File 'lib/maze/compare.rb', line 18

def keys
  @keys
end

#reasonsObject (readonly)

Returns the value of attribute reasons.



10
11
12
# File 'lib/maze/compare.rb', line 10

def reasons
  @reasons
end

Instance Method Details

#assert_equalObject

Provides a standard assertion of equality, with standardised output



42
43
44
# File 'lib/maze/compare.rb', line 42

def assert_equal
  Maze.check.true(@equal, "The compared fields do not match:\n #{result.reasons.join('\n')}")
end

#equal?Boolean

Indicates if the values compared to produced this result were equal

Returns:

  • (Boolean)

    Whether the elements were equal



30
31
32
# File 'lib/maze/compare.rb', line 30

def equal?
  @equal
end

#keypathString

Returns the keys traversed in order to compare the end values

Returns:

  • (String)

    The keypath used in the test



37
38
39
# File 'lib/maze/compare.rb', line 37

def keypath
  keys.length > 0 ? keys.reverse.join('.') : '<root>'
end