Class: RSpec::Hermetic::Snapshot
- Inherits:
-
Object
- Object
- RSpec::Hermetic::Snapshot
- Defined in:
- lib/rspec/hermetic/snapshot.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#timings ⇒ Object
readonly
Returns the value of attribute timings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data:, errors: {}, timings: {}) ⇒ Snapshot
constructor
A new instance of Snapshot.
Constructor Details
#initialize(data:, errors: {}, timings: {}) ⇒ Snapshot
Returns a new instance of Snapshot.
8 9 10 11 12 |
# File 'lib/rspec/hermetic/snapshot.rb', line 8 def initialize(data:, errors: {}, timings: {}) @data = data @errors = errors @timings = timings end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/rspec/hermetic/snapshot.rb', line 6 def data @data end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/rspec/hermetic/snapshot.rb', line 6 def errors @errors end |
#timings ⇒ Object (readonly)
Returns the value of attribute timings.
6 7 8 |
# File 'lib/rspec/hermetic/snapshot.rb', line 6 def timings @timings end |
Class Method Details
.capture(probes, context: nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rspec/hermetic/snapshot.rb', line 14 def self.capture(probes, context: nil) data = {} errors = {} timings = {} probes.each do |probe| started_at = monotonic_now data[probe.name] = probe.capture(context) rescue StandardError => error errors[probe.name] = "#{error.class}: #{error.}" data[probe.name] = {} ensure timings[probe.name] = monotonic_now - started_at if started_at end new(data: data, errors: errors, timings: timings) end |
.monotonic_now ⇒ Object
32 33 34 |
# File 'lib/rspec/hermetic/snapshot.rb', line 32 def self.monotonic_now Process.clock_gettime(Process::CLOCK_MONOTONIC) end |