exception_manager 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/README.md +3 -0
- data/lib/exception_manager.rb +2 -0
- data/lib/exception_manager/config.rb +4 -0
- data/lib/exception_manager/methods/locals.rb +1 -0
- data/lib/exception_manager/methods/subject.rb +1 -0
- data/lib/exception_manager/methods/subject_class_variables.rb +1 -0
- data/lib/exception_manager/methods/subject_instance_variables.rb +1 -0
- data/lib/exception_manager/version.rb +1 -1
- data/spec/exception_manager/patch_spec.rb +20 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2b7bd30e1110138537b3d70ee54266961f104a1
|
4
|
+
data.tar.gz: 07e922005c2cc946ee42659ba04e62c0d337d601
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93a042dffe11b970638082809d42b1e988a77afa8a9db563616dc09c5da3730020d5eded8ffca591c167a551dfa8077ea0996fedbeab5da2adf9e099919c92b3
|
7
|
+
data.tar.gz: e305069cddbef11b3a40246cb471b646b1e63d9141fa7ce5787cad91c532951d330927c85c77f978eb9031352831b4cac11e9d4682399035bacdee91442584b3
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/iliabylich/exception_manager.svg?branch=master)](https://travis-ci.org/iliabylich/exception_manager)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/iliabylich/exception_manager/badges/gpa.svg)](https://codeclimate.com/github/iliabylich/exception_manager)
|
3
|
+
|
1
4
|
# ExceptionManager
|
2
5
|
|
3
6
|
Gem for better exception recording.
|
data/lib/exception_manager.rb
CHANGED
@@ -10,6 +10,8 @@ module ExceptionManager
|
|
10
10
|
autoload :SubjectInstanceVariables, 'exception_manager/methods/subject_instance_variables'
|
11
11
|
autoload :SubjectClassVariables, 'exception_manager/methods/subject_class_variables'
|
12
12
|
end
|
13
|
+
|
14
|
+
DisabledError = Class.new(StandardError)
|
13
15
|
end
|
14
16
|
|
15
17
|
require 'exception_manager/patch'
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class ExceptionManager::Methods::SubjectInstanceVariables
|
2
2
|
def self.run(exception_binding)
|
3
|
+
ExceptionManager.required!
|
3
4
|
exception_binding.eval %q{
|
4
5
|
instance_variables.inject({}) do |hash, instance_variable_name|
|
5
6
|
hash[instance_variable_name] = instance_variable_get(instance_variable_name)
|
@@ -15,6 +15,16 @@ describe ExceptionManager do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
shared_examples 'requires ExceptionManager to be enabled' do |method_name|
|
19
|
+
context 'when ExceptionManager is disabled' do
|
20
|
+
before { ExceptionManager.disable! }
|
21
|
+
|
22
|
+
it 'raises error' do
|
23
|
+
expect { error.locals }.to raise_error(ExceptionManager::DisabledError)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
18
28
|
describe 'Exception#locals' do
|
19
29
|
let(:expected) do
|
20
30
|
{
|
@@ -26,12 +36,16 @@ describe ExceptionManager do
|
|
26
36
|
it 'returns Hash of local variables available when #raise happened' do
|
27
37
|
expect(error.locals).to eq(expected)
|
28
38
|
end
|
39
|
+
|
40
|
+
include_examples 'requires ExceptionManager to be enabled', :locals
|
29
41
|
end
|
30
42
|
|
31
43
|
describe 'Exception#subject' do
|
32
44
|
it 'returns context of place when subject was raised' do
|
33
45
|
expect(error.subject).to be_a(Letter)
|
34
46
|
end
|
47
|
+
|
48
|
+
include_examples 'requires ExceptionManager to be enabled', :locals
|
35
49
|
end
|
36
50
|
|
37
51
|
describe 'Exception#subject_instance_variables' do
|
@@ -45,6 +59,8 @@ describe ExceptionManager do
|
|
45
59
|
it 'returns instance variables of #subject when #raise happened' do
|
46
60
|
expect(error.subject_instance_variables).to eq(expected)
|
47
61
|
end
|
62
|
+
|
63
|
+
include_examples 'requires ExceptionManager to be enabled', :locals
|
48
64
|
end
|
49
65
|
|
50
66
|
describe 'Exception#subject_class_variables' do
|
@@ -57,6 +73,8 @@ describe ExceptionManager do
|
|
57
73
|
it 'returns class variables of #subject when #raise happened' do
|
58
74
|
expect(error.subject_class_variables).to eq(expected)
|
59
75
|
end
|
76
|
+
|
77
|
+
include_examples 'requires ExceptionManager to be enabled', :locals
|
60
78
|
end
|
61
79
|
|
62
80
|
describe 'Exception#summary' do
|
@@ -77,5 +95,7 @@ describe ExceptionManager do
|
|
77
95
|
expect(error.summary[:subject_instance_variables]).to be_a(Hash)
|
78
96
|
expect(error.summary[:subject_class_variables]).to be_a(Hash)
|
79
97
|
end
|
98
|
+
|
99
|
+
include_examples 'requires ExceptionManager to be enabled', :locals
|
80
100
|
end
|
81
101
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Bylich
|
@@ -75,6 +75,7 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- .gitignore
|
77
77
|
- .rspec
|
78
|
+
- .travis.yml
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|
80
81
|
- README.md
|