kensho-rspec 0.1.1 → 0.3.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/lib/kensho/rspec/formatter.rb +21 -0
- data/lib/kensho/rspec/helpers.rb +126 -13
- data/lib/kensho/rspec/state.rb +11 -1
- data/lib/kensho/rspec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dc8ed4404cde5d65a57ddb790ff3b68319a83330d58ae0d515e056da5870440f
|
|
4
|
+
data.tar.gz: 6edce31e3dbf35cea860c234a3e750d0abf6db0113fa90e9eab4cfdcca08e8e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ddb9d7d37d26699ed24366ebdc8756c6349872888183c0c2831f7afe17baacbb0ae9c38be9c7ada015be6de97e4eee433722bb18bee8b6f6edb7966ff3c9b1e
|
|
7
|
+
data.tar.gz: 36e0e59ff362f2e29a0720b3a8eb6f8c9af8e0bc4fa1b8ef73e3dac9cb44d50b0c87caf6c6372f190fe5132c721550d43bf3c02dd3233cc23eebc61b1dbf2004
|
|
@@ -330,6 +330,27 @@ module Kensho
|
|
|
330
330
|
case_obj['links'] = existing + scratch.links
|
|
331
331
|
end
|
|
332
332
|
|
|
333
|
+
# Runtime annotations win over metadata-derived values.
|
|
334
|
+
unless scratch.behavior.empty?
|
|
335
|
+
existing = case_obj['behavior'] || {}
|
|
336
|
+
case_obj['behavior'] = existing.merge(scratch.behavior)
|
|
337
|
+
end
|
|
338
|
+
unless scratch.parameters.empty?
|
|
339
|
+
existing = case_obj['parameters'] || []
|
|
340
|
+
case_obj['parameters'] = existing + scratch.parameters
|
|
341
|
+
end
|
|
342
|
+
unless scratch.tags.empty?
|
|
343
|
+
existing = case_obj['tags'] || []
|
|
344
|
+
merged = existing.dup
|
|
345
|
+
scratch.tags.each { |t| merged << t unless merged.include?(t) }
|
|
346
|
+
case_obj['tags'] = merged
|
|
347
|
+
end
|
|
348
|
+
case_obj['severity'] = scratch.severity if scratch.severity
|
|
349
|
+
case_obj['owner'] = scratch.owner if scratch.owner
|
|
350
|
+
case_obj['description'] = scratch.description if scratch.description
|
|
351
|
+
case_obj['flaky'] = true if scratch.flaky
|
|
352
|
+
case_obj['muted'] = true if scratch.muted
|
|
353
|
+
|
|
333
354
|
# Stdout/stderr captured by RSpec is wired up by an around-each
|
|
334
355
|
# hook (see Kensho::RSpec::Formatter.install_capture_hook) — see
|
|
335
356
|
# below.
|
data/lib/kensho/rspec/helpers.rb
CHANGED
|
@@ -92,14 +92,114 @@ module Kensho
|
|
|
92
92
|
nil
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
# Add a hyperlink to the running case. Positional `name` is the human
|
|
96
|
+
# label (legacy `label:`/`kind:` keywords still work). Default kind is
|
|
97
|
+
# 'link'.
|
|
98
|
+
def link(url, name = nil, kind: nil, label: nil)
|
|
99
|
+
add_link(url, kind: kind || 'link', label: name || label)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# A Jira/issue link. `id_or_url` may be a bare ticket id ('PROJ-1') or a
|
|
103
|
+
# full URL. Kind 'issue'.
|
|
104
|
+
def jira_link(id_or_url, label = nil)
|
|
105
|
+
add_link(id_or_url, kind: 'issue', label: label || id_or_url)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# A reference/documentation link. Kind 'reference'.
|
|
109
|
+
def reference_link(url, label = nil)
|
|
110
|
+
add_link(url, kind: 'reference', label: label)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# behavior.epic + labels.epic
|
|
114
|
+
def epic(name)
|
|
115
|
+
apply_behavior_runtime('epic', 'epic', name)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# behavior.feature + labels.feature
|
|
119
|
+
def feature(name)
|
|
120
|
+
apply_behavior_runtime('feature', 'feature', name)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# behavior.scenario + labels.story
|
|
124
|
+
def story(name)
|
|
125
|
+
apply_behavior_runtime('scenario', 'story', name)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Set case.severity. Only the five canonical names are accepted; anything
|
|
129
|
+
# else is ignored.
|
|
130
|
+
def severity(value)
|
|
96
131
|
scratch = Kensho::RSpec::State.current
|
|
97
|
-
return if scratch.nil? ||
|
|
132
|
+
return if scratch.nil? || value.nil?
|
|
98
133
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
134
|
+
v = value.to_s
|
|
135
|
+
scratch.severity = v if Kensho::Schema::SEVERITY.include?(v)
|
|
136
|
+
nil
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Set case.owner.
|
|
140
|
+
def owner(value)
|
|
141
|
+
scratch = Kensho::RSpec::State.current
|
|
142
|
+
return if scratch.nil? || value.nil?
|
|
143
|
+
|
|
144
|
+
scratch.owner = value.to_s
|
|
145
|
+
nil
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Set case.description.
|
|
149
|
+
def description(text)
|
|
150
|
+
scratch = Kensho::RSpec::State.current
|
|
151
|
+
return if scratch.nil? || text.nil?
|
|
152
|
+
|
|
153
|
+
scratch.description = text.to_s
|
|
154
|
+
nil
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Add a tag to the running case. Strips a leading '@' and de-dupes.
|
|
158
|
+
def tag(name)
|
|
159
|
+
scratch = Kensho::RSpec::State.current
|
|
160
|
+
return if scratch.nil? || name.nil?
|
|
161
|
+
|
|
162
|
+
t = name.to_s.sub(/\A@/, '')
|
|
163
|
+
return if t.empty?
|
|
164
|
+
|
|
165
|
+
scratch.tags << t unless scratch.tags.include?(t)
|
|
166
|
+
nil
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# Add a parameter (name/value) to the running case. No kind.
|
|
170
|
+
def parameter(name, value)
|
|
171
|
+
scratch = Kensho::RSpec::State.current
|
|
172
|
+
return if scratch.nil? || name.nil? || name.to_s.empty?
|
|
173
|
+
|
|
174
|
+
scratch.parameters << { 'name' => name.to_s, 'value' => value.to_s }
|
|
175
|
+
nil
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Mark the running case as flaky.
|
|
179
|
+
def flaky
|
|
180
|
+
scratch = Kensho::RSpec::State.current
|
|
181
|
+
return if scratch.nil?
|
|
182
|
+
|
|
183
|
+
scratch.flaky = true
|
|
184
|
+
nil
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Mark the running case as muted (known failure not counted by the gate).
|
|
188
|
+
def muted
|
|
189
|
+
scratch = Kensho::RSpec::State.current
|
|
190
|
+
return if scratch.nil?
|
|
191
|
+
|
|
192
|
+
scratch.muted = true
|
|
193
|
+
nil
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# A known issue: mutes the case and records an 'issue' link.
|
|
197
|
+
def known_issue(id_or_url, label = nil)
|
|
198
|
+
scratch = Kensho::RSpec::State.current
|
|
199
|
+
return if scratch.nil?
|
|
200
|
+
|
|
201
|
+
scratch.muted = true
|
|
202
|
+
jira_link(id_or_url, label)
|
|
103
203
|
nil
|
|
104
204
|
end
|
|
105
205
|
|
|
@@ -110,6 +210,26 @@ module Kensho
|
|
|
110
210
|
|
|
111
211
|
private
|
|
112
212
|
|
|
213
|
+
def add_link(url, kind:, label:)
|
|
214
|
+
scratch = Kensho::RSpec::State.current
|
|
215
|
+
return if scratch.nil? || url.nil? || url.to_s.empty?
|
|
216
|
+
|
|
217
|
+
entry = { 'url' => url.to_s }
|
|
218
|
+
entry['kind'] = kind.to_s if kind && !kind.to_s.empty?
|
|
219
|
+
entry['label'] = label.to_s if label && !label.to_s.empty?
|
|
220
|
+
scratch.links << entry
|
|
221
|
+
nil
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def apply_behavior_runtime(behavior_key, label_key, value)
|
|
225
|
+
scratch = Kensho::RSpec::State.current
|
|
226
|
+
return if scratch.nil? || value.nil? || value.to_s.empty?
|
|
227
|
+
|
|
228
|
+
scratch.behavior[behavior_key] = value.to_s
|
|
229
|
+
scratch.labels[label_key] = value.to_s
|
|
230
|
+
nil
|
|
231
|
+
end
|
|
232
|
+
|
|
113
233
|
def monotonic_now
|
|
114
234
|
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
115
235
|
end
|
|
@@ -144,13 +264,6 @@ module Kensho
|
|
|
144
264
|
group.metadata[key] = value.to_s
|
|
145
265
|
nil
|
|
146
266
|
end
|
|
147
|
-
|
|
148
|
-
# Lowercase aliases for callers who'd rather not use uppercase methods.
|
|
149
|
-
class << self
|
|
150
|
-
alias_method :feature, :Feature
|
|
151
|
-
alias_method :epic, :Epic
|
|
152
|
-
alias_method :story, :Story
|
|
153
|
-
end
|
|
154
267
|
end
|
|
155
268
|
|
|
156
269
|
# Hook into RSpec's example-group definition so we can track the
|
data/lib/kensho/rspec/state.rb
CHANGED
|
@@ -15,7 +15,9 @@ module Kensho
|
|
|
15
15
|
module RSpec
|
|
16
16
|
class CaseScratch
|
|
17
17
|
attr_accessor :case_id, :example_id, :started_at_ms,
|
|
18
|
-
:steps, :step_stack, :attachments, :logs, :labels, :links
|
|
18
|
+
:steps, :step_stack, :attachments, :logs, :labels, :links,
|
|
19
|
+
:parameters, :tags, :behavior, :severity, :owner,
|
|
20
|
+
:description, :flaky, :muted
|
|
19
21
|
|
|
20
22
|
def initialize(case_id:, example_id:, started_at_ms:)
|
|
21
23
|
@case_id = case_id
|
|
@@ -27,6 +29,14 @@ module Kensho
|
|
|
27
29
|
@logs = []
|
|
28
30
|
@labels = {}
|
|
29
31
|
@links = []
|
|
32
|
+
@parameters = []
|
|
33
|
+
@tags = []
|
|
34
|
+
@behavior = {}
|
|
35
|
+
@severity = nil
|
|
36
|
+
@owner = nil
|
|
37
|
+
@description = nil
|
|
38
|
+
@flaky = false
|
|
39
|
+
@muted = false
|
|
30
40
|
end
|
|
31
41
|
end
|
|
32
42
|
|
data/lib/kensho/rspec/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kensho-rspec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- KaizenReport
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec-core
|