stable 1.5.1 → 1.7.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/stable/spec.rb +31 -11
- 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: 705f529d889248982d60df5c8257a80ddca578714403e68b8a60f7f88478223a
|
4
|
+
data.tar.gz: e8ace2f93edb08e1981750332c6034408a9d12cc08e2b7a0c1b07b64ca032496
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f51fb0d25f5b0318a8a5759d0849b16d93bd8187bf5ddd97fa2aad4a584e3a18c1f5e24374d164d8f07ad03edc79a4127341bf47099c600544fed0bffb866671
|
7
|
+
data.tar.gz: da63baa93a76c20c46b51ed5c9fff23671797a46b698d7b277e8db5dafa03c924afe5f32f296051755738613d4c25d8e8dfd35af6b6c951327580eddb10e2296
|
data/lib/stable/spec.rb
CHANGED
@@ -8,15 +8,14 @@ module Stable
|
|
8
8
|
# outputs. it's a self-contained, serializable representation of a method's
|
9
9
|
# behavior at a specific point in time.
|
10
10
|
class Spec
|
11
|
-
attr_reader :class_name, :method_name, :args, :result, :error, :
|
11
|
+
attr_reader :class_name, :method_name, :args, :result, :error, :actual_result, :actual_error, :status, :uuid, :signature
|
12
12
|
|
13
|
-
def initialize(class_name:, method_name:, args:, result: nil, error: nil,
|
13
|
+
def initialize(class_name:, method_name:, args:, result: nil, error: nil, uuid: SecureRandom.uuid)
|
14
14
|
@class_name = class_name
|
15
15
|
@method_name = method_name
|
16
16
|
@args = args
|
17
17
|
@result = result
|
18
18
|
@error = error
|
19
|
-
@timestamp = timestamp
|
20
19
|
@status = :pending
|
21
20
|
@uuid = uuid
|
22
21
|
@signature = Digest::SHA256.hexdigest("#{class_name}##{method_name}:#{args.to_json}")
|
@@ -51,14 +50,14 @@ module Stable
|
|
51
50
|
short_sig = signature[0..6]
|
52
51
|
desc = "#{short_uuid}/#{short_sig}"
|
53
52
|
call = "#{class_name}##{method_name}(#{args.join(', ')})"
|
53
|
+
status_code = _status_code
|
54
|
+
error_code = _error_code
|
54
55
|
|
55
56
|
case status
|
56
|
-
when :passed
|
57
|
-
"#{desc} #{
|
58
|
-
when :passed_with_error
|
59
|
-
"#{desc} #{_green('P')} (error) #{call}"
|
57
|
+
when :passed, :passed_with_error
|
58
|
+
"#{desc} #{status_code}#{error_code} #{call}"
|
60
59
|
when :failed
|
61
|
-
lines = ["#{desc} #{
|
60
|
+
lines = ["#{desc} #{status_code}#{error_code} #{call}"]
|
62
61
|
if actual_error
|
63
62
|
if error
|
64
63
|
lines << " Expected error: #{error['class']}"
|
@@ -78,7 +77,7 @@ module Stable
|
|
78
77
|
end
|
79
78
|
lines.join("\n")
|
80
79
|
else
|
81
|
-
"#{desc} #{
|
80
|
+
"#{desc} #{status_code}#{error_code} #{call}"
|
82
81
|
end
|
83
82
|
end
|
84
83
|
|
@@ -89,7 +88,6 @@ module Stable
|
|
89
88
|
args: args,
|
90
89
|
result: result,
|
91
90
|
error: error,
|
92
|
-
timestamp: timestamp,
|
93
91
|
uuid: uuid,
|
94
92
|
signature: signature
|
95
93
|
}.compact.to_json
|
@@ -103,7 +101,6 @@ module Stable
|
|
103
101
|
args: data['args'],
|
104
102
|
result: data['result'],
|
105
103
|
error: data['error'],
|
106
|
-
timestamp: data['timestamp'],
|
107
104
|
uuid: data['uuid']
|
108
105
|
)
|
109
106
|
end
|
@@ -119,5 +116,28 @@ module Stable
|
|
119
116
|
def _yellow(text)
|
120
117
|
"\e[33m#{text}\e[0m"
|
121
118
|
end
|
119
|
+
|
120
|
+
def _light_blue(text)
|
121
|
+
"\e[94m#{text}\e[0m"
|
122
|
+
end
|
123
|
+
|
124
|
+
def _status_code
|
125
|
+
case status
|
126
|
+
when :passed, :passed_with_error
|
127
|
+
_green('P')
|
128
|
+
when :failed
|
129
|
+
_red('F')
|
130
|
+
else
|
131
|
+
_yellow('?')
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def _error_code
|
136
|
+
if error || actual_error
|
137
|
+
_light_blue('E')
|
138
|
+
else
|
139
|
+
_green('N')
|
140
|
+
end
|
141
|
+
end
|
122
142
|
end
|
123
143
|
end
|