Class: Lookout::Expect::Exception
- Defined in:
- lib/lookout-3.0/expect/exception.rb
Overview
Expect block of Lookout::Expected::Exceptions.
Instance Method Summary collapse
-
#call ⇒ Results::Error, ...
Evaluates the expect block and checks the first raised Exception against the expected Exception.
Instance Method Details
#call ⇒ Results::Error, ...
Evaluates the expect block and checks the first raised Exception against the expected Exception. If no exception is raised, the actual result is checked against the expected value.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lookout-3.0/expect/exception.rb', line 11 def call begin result = evaluate_block rescue Exception => actual exception = Lookout::Exception.new(actual) expected_class = expected.expected.class rescue Exception actual_class = exception.type return ((expected_class == actual_class) rescue false) ? check(actual) : Lookout::Results::Error. new(file, line, expected_class.to_lookout_expected.difference(actual_class)., exception) end check(result) rescue Exception => e Lookout::Results::Error.new(file, line, nil, Lookout::Exception.new(e)) end |