exception_handling 0.2.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/mocha_patch.rb DELETED
@@ -1,63 +0,0 @@
1
- _ = ActiveSupport::Testing::SetupAndTeardown::ForClassicTestUnit
2
- module ActiveSupport::Testing::SetupAndTeardown::ForClassicTestUnit
3
- # This redefinition is unfortunate but test/unit shows us no alternative.
4
- # Doubly unfortunate: hax to support Mocha's hax.
5
- # Triply unfortunate to be monkey patching it here. -Colin
6
- def run(result)
7
- return if @method_name.to_s == "default_test"
8
-
9
- mocha_counter = retrieve_mocha_counter(self, result)
10
- yield(Test::Unit::TestCase::STARTED, name)
11
- @_result = result
12
-
13
- begin
14
- begin
15
- run_callbacks :setup do
16
- setup
17
- __send__(@method_name)
18
- mocha_verify(mocha_counter) if mocha_counter
19
- end
20
- rescue Mocha::ExpectationError => e
21
- add_failure(e.message, e.backtrace)
22
- rescue Test::Unit::AssertionFailedError => e
23
- add_failure(e.message, e.backtrace)
24
- rescue Exception => e
25
- raise if PASSTHROUGH_EXCEPTIONS.include?(e.class)
26
- add_error(e)
27
- ensure
28
- begin
29
- teardown
30
- run_callbacks :teardown
31
- rescue Mocha::ExpectationError => e
32
- add_failure(e.message, e.backtrace)
33
- rescue Test::Unit::AssertionFailedError => e
34
- add_failure(e.message, e.backtrace)
35
- rescue Exception => e
36
- raise if PASSTHROUGH_EXCEPTIONS.include?(e.class)
37
- add_error(e)
38
- end
39
- end
40
- ensure
41
- mocha_teardown if mocha_counter
42
- end
43
-
44
- result.add_run
45
- yield(Test::Unit::TestCase::FINISHED, name)
46
- end
47
-
48
- protected
49
-
50
- def retrieve_mocha_counter(test_case, result) #:nodoc:
51
- if respond_to?(:mocha_verify) # using mocha
52
- if defined?(Mocha::TestCaseAdapter::AssertionCounter)
53
- Mocha::TestCaseAdapter::AssertionCounter.new(result)
54
- elsif defined?(Mocha::Integration::TestUnit::AssertionCounter)
55
- Mocha::Integration::TestUnit::AssertionCounter.new(result)
56
- elsif defined?(Mocha::MonkeyPatching::TestUnit::AssertionCounter)
57
- Mocha::MonkeyPatching::TestUnit::AssertionCounter.new(result)
58
- else
59
- Mocha::Integration::AssertionCounter.new(test_case)
60
- end
61
- end
62
- end
63
- end