Class: RSpec::Hermetic::Probe::Globals

Inherits:
Base
  • Object
show all
Defined in:
lib/rspec/hermetic/probe/globals.rb

Constant Summary collapse

WATCHED_GLOBALS =
%i[
  $LOAD_PATH
  $LOADED_FEATURES
  $PROGRAM_NAME
  $VERBOSE
  $DEBUG
  $stdin
  $stdout
  $stderr
].freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize, #name

Constructor Details

This class inherits a constructor from RSpec::Hermetic::Probe::Base

Instance Method Details

#capture(_context) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/rspec/hermetic/probe/globals.rb', line 21

def capture(_context)
  WATCHED_GLOBALS.each_with_object({}) do |name, values|
    values[name.to_s] = StableValue.capture(eval(name.to_s, TOPLEVEL_BINDING))
  rescue StandardError => error
    values[name.to_s] = "#{error.class}: #{error.message}"
  end
end