stable 1.7.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stable/spec.rb +11 -7
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 705f529d889248982d60df5c8257a80ddca578714403e68b8a60f7f88478223a
4
- data.tar.gz: e8ace2f93edb08e1981750332c6034408a9d12cc08e2b7a0c1b07b64ca032496
3
+ metadata.gz: 40c4de8e46107f9c447b8c81a635fe18bb62cfbaaf892f8826ce0315fc3ced85
4
+ data.tar.gz: b6e18c6fab3b1e860121619230f206282d258b1c00957ea53964d785b9a5bcc4
5
5
  SHA512:
6
- metadata.gz: f51fb0d25f5b0318a8a5759d0849b16d93bd8187bf5ddd97fa2aad4a584e3a18c1f5e24374d164d8f07ad03edc79a4127341bf47099c600544fed0bffb866671
7
- data.tar.gz: da63baa93a76c20c46b51ed5c9fff23671797a46b698d7b277e8db5dafa03c924afe5f32f296051755738613d4c25d8e8dfd35af6b6c951327580eddb10e2296
6
+ metadata.gz: 8b9517ef8e4e79dae32f29bcdd97304dbfba939bdf4460a0dd743c43a68ad3531043f1751c35187783c091d2404d0b28429a50e25714544112ad8bfb4d41e67b
7
+ data.tar.gz: 1ab98ed03db10521fd6b888ba1ba62b0963e088db7d09bf4c0b8b359d2ff64fa039d12b9692439232d4fe92a32847c7bbb939320f2fd673407e9f86ad4af1c99
data/lib/stable/spec.rb CHANGED
@@ -8,9 +8,9 @@ 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, :actual_result, :actual_error, :status, :uuid, :signature
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, uuid: SecureRandom.uuid)
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
@@ -19,6 +19,7 @@ module Stable
19
19
  @status = :pending
20
20
  @uuid = uuid
21
21
  @signature = Digest::SHA256.hexdigest("#{class_name}##{method_name}:#{args.to_json}")
22
+ @name = name || SecureRandom.hex(8)
22
23
  end
23
24
 
24
25
  def run!
@@ -49,15 +50,16 @@ module Stable
49
50
  short_uuid = uuid.split('-').last
50
51
  short_sig = signature[0..6]
51
52
  desc = "#{short_uuid}/#{short_sig}"
53
+ name_str = name[..19].ljust(20)
52
54
  call = "#{class_name}##{method_name}(#{args.join(', ')})"
53
55
  status_code = _status_code
54
56
  error_code = _error_code
55
57
 
56
58
  case status
57
59
  when :passed, :passed_with_error
58
- "#{desc} #{status_code}#{error_code} #{call}"
60
+ "#{desc} #{name_str} #{status_code}#{error_code} #{call}"
59
61
  when :failed
60
- lines = ["#{desc} #{status_code}#{error_code} #{call}"]
62
+ lines = ["#{desc} #{name_str} #{status_code}#{error_code} #{call}"]
61
63
  if actual_error
62
64
  if error
63
65
  lines << " Expected error: #{error['class']}"
@@ -77,7 +79,7 @@ module Stable
77
79
  end
78
80
  lines.join("\n")
79
81
  else
80
- "#{desc} #{status_code}#{error_code} #{call}"
82
+ "#{desc} #{name_str} #{status_code}#{error_code} #{call}"
81
83
  end
82
84
  end
83
85
 
@@ -89,7 +91,8 @@ module Stable
89
91
  result: result,
90
92
  error: error,
91
93
  uuid: uuid,
92
- signature: signature
94
+ signature: signature,
95
+ name: name
93
96
  }.compact.to_json
94
97
  end
95
98
 
@@ -101,7 +104,8 @@ module Stable
101
104
  args: data['args'],
102
105
  result: data['result'],
103
106
  error: data['error'],
104
- uuid: data['uuid']
107
+ uuid: data['uuid'],
108
+ name: data['name']
105
109
  )
106
110
  end
107
111
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt