stable 1.6.0 → 1.8.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 +11 -10
- 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: 40c4de8e46107f9c447b8c81a635fe18bb62cfbaaf892f8826ce0315fc3ced85
|
4
|
+
data.tar.gz: b6e18c6fab3b1e860121619230f206282d258b1c00957ea53964d785b9a5bcc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b9517ef8e4e79dae32f29bcdd97304dbfba939bdf4460a0dd743c43a68ad3531043f1751c35187783c091d2404d0b28429a50e25714544112ad8bfb4d41e67b
|
7
|
+
data.tar.gz: 1ab98ed03db10521fd6b888ba1ba62b0963e088db7d09bf4c0b8b359d2ff64fa039d12b9692439232d4fe92a32847c7bbb939320f2fd673407e9f86ad4af1c99
|
data/lib/stable/spec.rb
CHANGED
@@ -8,18 +8,18 @@ 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, :name
|
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, name: nil)
|
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}")
|
22
|
+
@name = name || SecureRandom.hex(8)
|
23
23
|
end
|
24
24
|
|
25
25
|
def run!
|
@@ -50,15 +50,16 @@ module Stable
|
|
50
50
|
short_uuid = uuid.split('-').last
|
51
51
|
short_sig = signature[0..6]
|
52
52
|
desc = "#{short_uuid}/#{short_sig}"
|
53
|
+
name_str = name[..19].ljust(20)
|
53
54
|
call = "#{class_name}##{method_name}(#{args.join(', ')})"
|
54
55
|
status_code = _status_code
|
55
56
|
error_code = _error_code
|
56
57
|
|
57
58
|
case status
|
58
59
|
when :passed, :passed_with_error
|
59
|
-
"#{desc} #{status_code}#{error_code} #{call}"
|
60
|
+
"#{desc} #{name_str} #{status_code}#{error_code} #{call}"
|
60
61
|
when :failed
|
61
|
-
lines = ["#{desc} #{status_code}#{error_code} #{call}"]
|
62
|
+
lines = ["#{desc} #{name_str} #{status_code}#{error_code} #{call}"]
|
62
63
|
if actual_error
|
63
64
|
if error
|
64
65
|
lines << " Expected error: #{error['class']}"
|
@@ -78,7 +79,7 @@ module Stable
|
|
78
79
|
end
|
79
80
|
lines.join("\n")
|
80
81
|
else
|
81
|
-
"#{desc} #{status_code}#{error_code} #{call}"
|
82
|
+
"#{desc} #{name_str} #{status_code}#{error_code} #{call}"
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
@@ -89,9 +90,9 @@ module Stable
|
|
89
90
|
args: args,
|
90
91
|
result: result,
|
91
92
|
error: error,
|
92
|
-
timestamp: timestamp,
|
93
93
|
uuid: uuid,
|
94
|
-
signature: signature
|
94
|
+
signature: signature,
|
95
|
+
name: name
|
95
96
|
}.compact.to_json
|
96
97
|
end
|
97
98
|
|
@@ -103,8 +104,8 @@ module Stable
|
|
103
104
|
args: data['args'],
|
104
105
|
result: data['result'],
|
105
106
|
error: data['error'],
|
106
|
-
|
107
|
-
|
107
|
+
uuid: data['uuid'],
|
108
|
+
name: data['name']
|
108
109
|
)
|
109
110
|
end
|
110
111
|
|