capydash 0.2.2 → 0.2.3
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/capydash/rspec.rb +63 -79
- data/lib/capydash/version.rb +1 -1
- 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: 8120c468fac1e4d0e67b3190f2fd3905bf047a1628f66232cedbc3085e0af2f5
|
|
4
|
+
data.tar.gz: ea62c0dd462b95ad7a2405f0f139b9c9f3d5f3bfa0c9315b93e70ee39df094e0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b2cbd4509f3dc292b2dc3873ae74e03fa3315cf850cd9bc10dbddfe63926c4cd03f1003fa728b527a3f48906149375709d432b347b774366607114209ec58a8
|
|
7
|
+
data.tar.gz: ec5f1fb549172b312df50562c60c3e40a641518acd2f2e86e8288882a6c17820d4550cfe5824188ed50ea59567758a7af085010156ebec8b5806fb117e46ac74
|
data/lib/capydash/rspec.rb
CHANGED
|
@@ -5,54 +5,18 @@ require 'erb'
|
|
|
5
5
|
module CapyDash
|
|
6
6
|
module RSpec
|
|
7
7
|
class << self
|
|
8
|
-
|
|
9
|
-
return unless rspec_available?
|
|
10
|
-
return if @configured
|
|
11
|
-
|
|
12
|
-
begin
|
|
13
|
-
@configured = true
|
|
14
|
-
@results = []
|
|
15
|
-
@started_at = nil
|
|
16
|
-
|
|
17
|
-
::RSpec.configure do |config|
|
|
18
|
-
config.before(:suite) do
|
|
19
|
-
CapyDash::RSpec.start_run
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
config.after(:each) do |example|
|
|
23
|
-
CapyDash::RSpec.record_example(example)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
config.after(:suite) do
|
|
27
|
-
CapyDash::RSpec.generate_report
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
rescue => e
|
|
31
|
-
# If RSpec isn't ready, silently fail - it will be set up later
|
|
32
|
-
@configured = false
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
def rspec_available?
|
|
39
|
-
return false unless defined?(::RSpec)
|
|
40
|
-
return false unless ::RSpec.respond_to?(:configure)
|
|
41
|
-
true
|
|
42
|
-
rescue
|
|
43
|
-
false
|
|
44
|
-
end
|
|
45
|
-
|
|
8
|
+
# Public method: Called from RSpec before(:suite) hook
|
|
46
9
|
def start_run
|
|
47
10
|
@results = []
|
|
48
11
|
@started_at = Time.now
|
|
49
12
|
end
|
|
50
13
|
|
|
14
|
+
# Public method: Called from RSpec after(:each) hook
|
|
51
15
|
def record_example(example)
|
|
52
16
|
return unless @started_at
|
|
53
17
|
|
|
54
18
|
execution_result = example.execution_result
|
|
55
|
-
status = execution_result.status
|
|
19
|
+
status = normalize_status(execution_result.status)
|
|
56
20
|
|
|
57
21
|
error_message = nil
|
|
58
22
|
if execution_result.status == :failed && execution_result.exception
|
|
@@ -71,6 +35,7 @@ module CapyDash
|
|
|
71
35
|
}
|
|
72
36
|
end
|
|
73
37
|
|
|
38
|
+
# Public method: Called from RSpec after(:suite) hook
|
|
74
39
|
def generate_report
|
|
75
40
|
return unless @started_at
|
|
76
41
|
return if @results.empty?
|
|
@@ -123,8 +88,59 @@ module CapyDash
|
|
|
123
88
|
report_dir
|
|
124
89
|
end
|
|
125
90
|
|
|
91
|
+
# Public method: Sets up RSpec hooks
|
|
92
|
+
def setup!
|
|
93
|
+
return unless rspec_available?
|
|
94
|
+
return if @configured
|
|
95
|
+
|
|
96
|
+
begin
|
|
97
|
+
@configured = true
|
|
98
|
+
@results = []
|
|
99
|
+
@started_at = nil
|
|
100
|
+
|
|
101
|
+
::RSpec.configure do |config|
|
|
102
|
+
config.before(:suite) do
|
|
103
|
+
CapyDash::RSpec.start_run
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
config.after(:each) do |example|
|
|
107
|
+
CapyDash::RSpec.record_example(example)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
config.after(:suite) do
|
|
111
|
+
CapyDash::RSpec.generate_report
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
rescue => e
|
|
115
|
+
# If RSpec isn't ready, silently fail - it will be set up later
|
|
116
|
+
@configured = false
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
126
120
|
private
|
|
127
121
|
|
|
122
|
+
def rspec_available?
|
|
123
|
+
return false unless defined?(::RSpec)
|
|
124
|
+
return false unless ::RSpec.respond_to?(:configure)
|
|
125
|
+
true
|
|
126
|
+
rescue
|
|
127
|
+
false
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def normalize_status(status)
|
|
131
|
+
# Normalize RSpec status symbols to strings
|
|
132
|
+
case status
|
|
133
|
+
when :passed, 'passed'
|
|
134
|
+
'passed'
|
|
135
|
+
when :failed, 'failed'
|
|
136
|
+
'failed'
|
|
137
|
+
when :pending, 'pending'
|
|
138
|
+
'pending'
|
|
139
|
+
else
|
|
140
|
+
status.to_s
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
128
144
|
def extract_class_name(file_path)
|
|
129
145
|
return 'UnknownSpec' if file_path.nil? || file_path.empty?
|
|
130
146
|
|
|
@@ -221,38 +237,6 @@ module CapyDash
|
|
|
221
237
|
box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
|
|
222
238
|
}
|
|
223
239
|
|
|
224
|
-
.test-method.hidden {
|
|
225
|
-
display: none;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.test-class.hidden {
|
|
229
|
-
display: none;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.method-status {
|
|
233
|
-
padding: 0.25rem 0.75rem;
|
|
234
|
-
border-radius: 4px;
|
|
235
|
-
font-size: 0.75rem;
|
|
236
|
-
font-weight: 600;
|
|
237
|
-
text-transform: uppercase;
|
|
238
|
-
letter-spacing: 0.5px;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.method-status-passed {
|
|
242
|
-
background: #27ae60;
|
|
243
|
-
color: white;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
.method-status-failed {
|
|
247
|
-
background: #e74c3c;
|
|
248
|
-
color: white;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
.method-status-pending {
|
|
252
|
-
background: #f39c12;
|
|
253
|
-
color: white;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
240
|
.summary {
|
|
257
241
|
display: grid;
|
|
258
242
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
@@ -308,6 +292,10 @@ module CapyDash
|
|
|
308
292
|
border-bottom: none;
|
|
309
293
|
}
|
|
310
294
|
|
|
295
|
+
.test-class.hidden {
|
|
296
|
+
display: none;
|
|
297
|
+
}
|
|
298
|
+
|
|
311
299
|
.test-class h2 {
|
|
312
300
|
background: #f8f9fa;
|
|
313
301
|
padding: 1rem 1.5rem;
|
|
@@ -326,6 +314,10 @@ module CapyDash
|
|
|
326
314
|
border-bottom: none;
|
|
327
315
|
}
|
|
328
316
|
|
|
317
|
+
.test-method.hidden {
|
|
318
|
+
display: none;
|
|
319
|
+
}
|
|
320
|
+
|
|
329
321
|
.test-method-header {
|
|
330
322
|
display: flex;
|
|
331
323
|
align-items: center;
|
|
@@ -341,14 +333,6 @@ module CapyDash
|
|
|
341
333
|
flex: 1;
|
|
342
334
|
}
|
|
343
335
|
|
|
344
|
-
.test-method.hidden {
|
|
345
|
-
display: none;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
.test-class.hidden {
|
|
349
|
-
display: none;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
336
|
.method-status {
|
|
353
337
|
padding: 0.25rem 0.75rem;
|
|
354
338
|
border-radius: 4px;
|
data/lib/capydash/version.rb
CHANGED