Class: Lookout::Difference::Exception

Inherits:
Object show all
Defined in:
lib/lookout-3.0/difference/exception.rb

Overview

Difference reports between Exceptions. The report differs from that of Object in that it tries to “diff” the exception messages and that it uses ‘≉’ instead of ‘≠’ to show that the actual result doesn’t match an expected Regexp.

Instance Attribute Summary

Attributes inherited from Object

#actual, #expected

Instance Method Summary collapse

Methods inherited from Object

#==, #hash, #message, #to_s

Constructor Details

#initialize(actual, expected, regexp = nil) ⇒ Exception

Initializes a difference report between the ACTUAL result and the EXPECTED value, where REGEXP is the Regexp found inside EXPECTED, if any.

Parameters:



13
14
15
16
# File 'lib/lookout-3.0/difference/exception.rb', line 13

def initialize(actual, expected, regexp = nil)
  @regexp = regexp
  super actual, expected
end

Instance Method Details

#diffEnumerable<String>, super

Returns The result of String#diff between Object#expected’s message and Object#actual’s message if Object#actual and Object#expected are of the same class and Object#expected and Object#actual’s messages are Strings, super otherwise.

Returns:



22
23
24
25
26
27
28
29
# File 'lib/lookout-3.0/difference/exception.rb', line 22

def diff
  return super unless expected.class == actual.class and
    String === expected.message and
    not @regexp and
    (m = actual.message rescue nil) and
    String === m
  expected.message.to_lookout_expected.difference(m).diff
end