Method: Whitestone.call
- Defined in:
- lib/whitestone.rb
.call(block, sandbox = nil) ⇒ Object
Whitestone.call
Invokes the given block and debugs any exceptions that may arise as a result. The block can be from a Test object or a “before-each”-style block.
If an assertion fails or an error occurs during the running of a test, it is dealt with in this method (update the stats, update the test object, re-raise so the upstream method execute can abort the current test/scope.
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
# File 'lib/whitestone.rb', line 601 def call(block, sandbox = nil) begin @calls.push block if sandbox sandbox.instance_eval(&block) else block.call end rescue FailureOccurred => f ## A failure has occurred while running a test. We report the failure ## and re-raise the exception so that the calling code knows not to ## continue with this test. @stats[:fail] += 1 @current_test.result = :fail @output.report_failure( current_test, f., f.backtrace ) raise rescue Exception, AssertionSpecificationError => e ## An error has occurred while running a test. ## OR ## An assertion was not properly specified. ## ## We record and report the error and then raise Whitestone::ErrorOccurred ## so that the code running the test knows an error occurred. It ## doesn't need to do anything with the error; it's just a signal. @stats[:error] += 1 @current_test.result = :error @current_test.error = e if e.class == AssertionSpecificationError @output.report_uncaught_exception( current_test, e, @calls, :filter ) else @output.report_uncaught_exception( current_test, e, @calls ) end raise ErrorOccurred ensure @calls.pop end end |