enhanced_errors 2.0.2 → 2.0.4
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/enhanced_errors.gemspec +1 -1
- data/lib/enhanced_errors.rb +30 -18
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8930564c886592e2009e80692afc91e246a3568c5aa3014cc8c75cc9707ab79
|
4
|
+
data.tar.gz: 50f4106e4f94eaaadde9a0e1a1ef3f6783863edfbba7a40a95453c3fb82b6f9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1e15a12dc7fe9823160a57d989fc281dd53bdbdfac17dc249be8f6e821c44cf2c089c1c7414b42245dc9be2c63ff98efb723ef26cb63550d019f8d48e7457d0
|
7
|
+
data.tar.gz: cda1322bd0d6371ed9f12a7faf165dfd4f838387b98c1d34c22c03c89534e5b2de4570894d941ef22c7019278cad0ee569984e6abc6632403e563051044acbcb
|
data/enhanced_errors.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "enhanced_errors"
|
3
|
-
spec.version = "2.0.
|
3
|
+
spec.version = "2.0.4"
|
4
4
|
spec.authors = ["Eric Beland"]
|
5
5
|
|
6
6
|
spec.summary = "Automatically enhance your errors with messages containing variable values from the moment they were raised."
|
data/lib/enhanced_errors.rb
CHANGED
@@ -199,16 +199,16 @@ class EnhancedErrors
|
|
199
199
|
@rspec_tracepoint = TracePoint.new(:b_return) do |tp|
|
200
200
|
# This is super-kluge-y and should be replaced with... something TBD
|
201
201
|
|
202
|
-
#
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
tp.path.to_s =~ /_spec\.rb$/
|
209
|
-
@rspec_example_binding = tp.binding
|
202
|
+
# early easy checks to nope out of the object name and other checks
|
203
|
+
if tp.method_id.nil? && !(tp.path.to_s =~ /rspec/) && tp.path.to_s =~ /_spec\.rb$/
|
204
|
+
# fixes cases where class and name are screwed up or overridden
|
205
|
+
if determine_object_name(tp) =~ /RSpec::ExampleGroups::[A-Z0-9]+.*/ &&
|
206
|
+
@rspec_example_binding = tp.binding
|
207
|
+
end
|
210
208
|
end
|
209
|
+
|
211
210
|
end
|
211
|
+
|
212
212
|
@rspec_tracepoint.enable
|
213
213
|
end
|
214
214
|
|
@@ -580,17 +580,29 @@ class EnhancedErrors
|
|
580
580
|
end
|
581
581
|
|
582
582
|
def determine_object_name(tp, method_name = '')
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
583
|
+
begin
|
584
|
+
# These tricks are used to get around the fact that `tp.self` can be a class that is
|
585
|
+
# wired up with method_missing where every direct call alters the class. This is true
|
586
|
+
# on certain builders or config objects and caused problems.
|
587
|
+
|
588
|
+
# Directly bind and call the `class` method to avoid triggering `method_missing`
|
589
|
+
self_class = Object.instance_method(:class).bind(tp.self).call
|
590
|
+
|
591
|
+
# Similarly, bind and call `singleton_class` safely
|
592
|
+
singleton_class = Object.instance_method(:singleton_class).bind(tp.self).call
|
593
|
+
|
594
|
+
if self_class && tp.defined_class == singleton_class
|
595
|
+
object_identifier = safe_to_s(tp.self)
|
596
|
+
method_suffix = method_name && !method_name.empty? ? ".#{method_name}" : ""
|
597
|
+
"#{object_identifier}#{method_suffix}"
|
598
|
+
else
|
599
|
+
object_class_name = safe_to_s(self_class.name || 'UnknownClass')
|
600
|
+
method_suffix = method_name && !method_name.empty? ? "##{method_name}" : ""
|
601
|
+
"#{object_class_name}#{method_suffix}"
|
602
|
+
end
|
603
|
+
rescue Exception => e
|
604
|
+
'[ErrorGettingName]'
|
591
605
|
end
|
592
|
-
rescue Exception => e
|
593
|
-
'[ErrorGettingName]'
|
594
606
|
end
|
595
607
|
|
596
608
|
def get_global_variable_value(var)
|