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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +47 -2
- data/README.md +109 -0
- data/Rakefile +12 -4
- data/exception_handling.gemspec +23 -19
- data/lib/exception_handling/log_stub_error.rb +84 -0
- data/lib/{exception_handling_mailer.rb → exception_handling/mailer.rb} +1 -1
- data/lib/exception_handling/methods.rb +69 -0
- data/lib/exception_handling/testing.rb +65 -0
- data/lib/exception_handling/version.rb +1 -1
- data/lib/exception_handling.rb +127 -91
- data/test/test_helper.rb +55 -2
- data/test/unit/exception_handling/log_error_stub_test.rb +83 -0
- data/test/unit/exception_handling/mailer_test.rb +79 -0
- data/test/unit/exception_handling/methods_test.rb +59 -0
- data/test/unit/exception_handling_test.rb +717 -0
- data/views/exception_handling/mailer/exception_notification.html.erb +4 -1
- metadata +62 -13
- data/README +0 -1
- data/test/exception_handling_test.rb +0 -977
- data/test/mocha_patch.rb +0 -63
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
|