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.



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