rspec-enriched_json 0.8.0 → 0.8.2
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 394af05d97929e94bd1c9b39aead58ab1254b7208f2f6be5c4dc07cb761d6d3a
|
|
4
|
+
data.tar.gz: c23222189bcb9497bf8201847968136ec9a5323e1db191b0d4548e261688b7b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ca7f20e71192f8dae52d73544b7971ccafacc425c30aa4c98ca33cc45e9d0c8723d8e0b7480aff717da4a6c8dc106229957f0d97968117593faacc2f8812ea06
|
|
7
|
+
data.tar.gz: d90481ce505fd5badf38037ef7610d1215a5959472460f0a43d2f1d9ad027c158c51fc14f0d34f4cc1a291eabc583f09654706cc4b73f088e11a0f59be0ad73f
|
|
@@ -7,8 +7,20 @@ module RSpec
|
|
|
7
7
|
module EnrichedJson
|
|
8
8
|
module Formatters
|
|
9
9
|
class EnrichedJsonFormatter < RSpec::Core::Formatters::JsonFormatter
|
|
10
|
+
ANSI_COLOR_REGEX = /\e\[[0-9;]*[mGKHF]/
|
|
11
|
+
EXCEPTION_DETECTOR_REGEX = /(Exception|Error|undefined method|uninitialized constant)/
|
|
12
|
+
PATH_AND_LINE_NUMBER_REGEX = /#?(?<path>.+?):(?<line_number>\d+)/
|
|
13
|
+
EXCEPTION_CLASS_AND_MESSAGE_REGEX = /^(?<exception_class>[A-Z]\w*Error|Exception):$\n(?<exception_message>(?<extra>^\s\s.*\n?)+)/
|
|
14
|
+
|
|
10
15
|
RSpec::Core::Formatters.register self, :message, :dump_summary, :dump_profile, :stop, :seed, :close
|
|
11
16
|
|
|
17
|
+
def initialize(output)
|
|
18
|
+
super
|
|
19
|
+
@output_hash = {
|
|
20
|
+
errors: []
|
|
21
|
+
}
|
|
22
|
+
end
|
|
23
|
+
|
|
12
24
|
def stop(group_notification)
|
|
13
25
|
@output_hash[:examples] = group_notification.notifications.map do |notification|
|
|
14
26
|
format_example(notification.example).tap do |hash|
|
|
@@ -36,6 +48,30 @@ module RSpec
|
|
|
36
48
|
end
|
|
37
49
|
end
|
|
38
50
|
|
|
51
|
+
def message(notification)
|
|
52
|
+
super
|
|
53
|
+
|
|
54
|
+
if notification.message.match?(EXCEPTION_DETECTOR_REGEX)
|
|
55
|
+
clean_message = notification.message.gsub(ANSI_COLOR_REGEX, "")
|
|
56
|
+
|
|
57
|
+
error_info = {
|
|
58
|
+
message: clean_message
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (match = clean_message.match(PATH_AND_LINE_NUMBER_REGEX))
|
|
62
|
+
error_info[:path] = match.named_captures["path"]
|
|
63
|
+
error_info[:line_number] = match.named_captures["line_number"]
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
if (match = clean_message.match(EXCEPTION_CLASS_AND_MESSAGE_REGEX))
|
|
67
|
+
error_info[:exception_class] = match.named_captures["exception_class"]
|
|
68
|
+
error_info[:exception_message] = match.named_captures["exception_message"]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
@output_hash[:errors] << error_info
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
39
75
|
private
|
|
40
76
|
|
|
41
77
|
def add_metadata(hash, example)
|