rspec-enriched_json 0.8.0 → 0.8.1
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: 38e0b42e938c66b19488f41d16546f31133a75fec86b9a3bee4a7aa896f7250d
|
4
|
+
data.tar.gz: 441d97065e302a739495ddac8ba571d26892eb6fb59fc4b1de687b9ca0b0dd36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d9f98cf81ab1d0d87c19e0d929b9670d331ee127fe3dbdd7658437a4bef7b9477ad64ce94093e21c0ea5618b6e99e222acb00e668718d1bab9af97503e293aa
|
7
|
+
data.tar.gz: c62c8a727458ace70279ae5fd703b4e91397dff7aff54a2ccba805f37a02a68cd1bfdb46235325d372e652ae3ddcd24dbec5381cf42627b78c3532e77d10483f
|
@@ -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)
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-enriched_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raghu Betina
|
8
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
|
-
date:
|
11
|
+
date: 2025-08-04 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: rspec-core
|
@@ -100,8 +101,8 @@ email:
|
|
100
101
|
executables: []
|
101
102
|
extensions: []
|
102
103
|
extra_rdoc_files:
|
103
|
-
- LICENSE.md
|
104
104
|
- README.md
|
105
|
+
- LICENSE.md
|
105
106
|
files:
|
106
107
|
- LICENSE.md
|
107
108
|
- README.md
|
@@ -120,6 +121,7 @@ metadata:
|
|
120
121
|
homepage_uri: https://github.com/firstdraft/rspec-enriched_json
|
121
122
|
rubygems_mfa_required: 'true'
|
122
123
|
source_code_uri: https://github.com/firstdraft/rspec-enriched_json
|
124
|
+
post_install_message:
|
123
125
|
rdoc_options: []
|
124
126
|
require_paths:
|
125
127
|
- lib
|
@@ -134,7 +136,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
136
|
- !ruby/object:Gem::Version
|
135
137
|
version: '0'
|
136
138
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
139
|
+
rubygems_version: 3.5.16
|
140
|
+
signing_key:
|
138
141
|
specification_version: 4
|
139
142
|
summary: Enriches RSpec JSON output with structured failure data
|
140
143
|
test_files: []
|