Class: Lookout::Expect::Classes::Exception

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

Overview

Instance Method Summary collapse

Instance Method Details

#callResults::Error, ...

Evaluates the expect block and checks the first raised Exception’s class against the expected Exception class. If no exception is raised, the actual result is checked against the expected value.

Returns:

  • (Results::Error)

    If the raised exception’s class isn’t equal to or a descendant of the expected result class

  • (Results::Success)

    If the raised exception’s class is equal to or a descendant of the expected result class

  • (Results::Success)

    If there are no differences between the actual result and the expected value

  • (Results::Failure)

    If there are differences between the actual result and the expected value



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/lookout-3.0/expect/classes/exception.rb', line 13

def call
  begin
    result = evaluate_block
  rescue expected.expected
    return Lookout::Results::Success.new(file, line)
  rescue Exception => e
    exception = Lookout::Exception.new(e)
    return Lookout::Results::Error.
      new(file, line, expected.difference(exception.type).message, exception)
  end
  check(result)
rescue Exception => e
  Lookout::Results::Error.new(file, line, nil, Lookout::Exception.new(e))
end