Module: RSpec::Hermetic

Defined in:
lib/rspec/hermetic.rb,
lib/rspec/hermetic/diff.rb,
lib/rspec/hermetic/probe.rb,
lib/rspec/hermetic/change.rb,
lib/rspec/hermetic/runner.rb,
lib/rspec/hermetic/verdict.rb,
lib/rspec/hermetic/version.rb,
lib/rspec/hermetic/forensic.rb,
lib/rspec/hermetic/minitest.rb,
lib/rspec/hermetic/restorer.rb,
lib/rspec/hermetic/snapshot.rb,
lib/rspec/hermetic/allowlist.rb,
lib/rspec/hermetic/formatter.rb,
lib/rspec/hermetic/probe/env.rb,
lib/rspec/hermetic/evaluation.rb,
lib/rspec/hermetic/probe/base.rb,
lib/rspec/hermetic/probe/time.rb,
lib/rspec/hermetic/probe/rails.rb,
lib/rspec/hermetic/verify_task.rb,
lib/rspec/hermetic/stable_value.rb,
lib/rspec/hermetic/configuration.rb,
lib/rspec/hermetic/probe/globals.rb,
lib/rspec/hermetic/evaluation_task.rb,
lib/rspec/hermetic/probe/constants.rb,
lib/rspec/hermetic/probe/resources.rb,
lib/rspec/hermetic/candidate_report.rb,
lib/rspec/hermetic/probe/filesystem.rb,
lib/rspec/hermetic/probe/randomness.rb,
lib/rspec/hermetic/resource_tracker.rb,
lib/rspec/hermetic/corpus_evaluation.rb,
lib/rspec/hermetic/probe/ruby_runtime.rb,
sig/rspec/hermetic.rbs

Defined Under Namespace

Modules: Forensic, Minitest, Probe, ResourceTracker, StableValue Classes: Allowlist, CandidateReport, Change, ChangeSet, Configuration, CorpusEvaluation, Diff, Error, Evaluation, EvaluationTask, Formatter, Restorer, Runner, Snapshot, Verdict, VerifyTask

Constant Summary collapse

MISSING_VALUE =
Object.new.freeze
VERSION =

Returns:

  • (String)
"0.1.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.minitest_runnerObject (readonly)

Returns the value of attribute minitest_runner.



68
69
70
# File 'lib/rspec/hermetic/minitest.rb', line 68

def minitest_runner
  @minitest_runner
end

.runnerObject (readonly)

Returns the value of attribute runner.



12
13
14
# File 'lib/rspec/hermetic.rb', line 12

def runner
  @runner
end

Class Method Details

.configurationConfiguration

Returns:



14
15
16
# File 'lib/rspec/hermetic.rb', line 14

def configuration
  @configuration ||= Configuration.new
end

.configure(rspec_config = nil) {|configuration| ... } ⇒ Configuration

Parameters:

  • rspec_config (Object) (defaults to: nil)

Yields:

Yield Parameters:

Yield Returns:

  • (Object)

Returns:



18
19
20
21
22
# File 'lib/rspec/hermetic.rb', line 18

def configure(rspec_config = nil)
  yield configuration if block_given?
  install!(rspec_config) if rspec_config
  configuration
end

.configure_minitest {|configuration| ... } ⇒ Configuration

Yields:

Yield Parameters:

Yield Returns:

  • (Object)

Returns:



70
71
72
73
74
75
# File 'lib/rspec/hermetic/minitest.rb', line 70

def configure_minitest
  yield configuration if block_given?
  @minitest_runner = Runner.new(configuration)
  Minitest.install!
  configuration
end

.install!(rspec_config) ⇒ Object

Parameters:

  • rspec_config (Object)

Returns:

  • (Object)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rspec/hermetic.rb', line 24

def install!(rspec_config)
  @installed_config_ids ||= {}
  return if @installed_config_ids[rspec_config.object_id]

  @runner = Runner.new(configuration)
  hook = proc { |example| ::RSpec::Hermetic.runner.call(example, self) }

  if rspec_config.respond_to?(:hooks) && rspec_config.hooks.respond_to?(:register)
    install_outer_around_hook(rspec_config, hook)
  elsif rspec_config.respond_to?(:prepend_around)
    rspec_config.prepend_around(:each, &hook)
  else
    rspec_config.around(:each, &hook)
  end

  @installed_config_ids[rspec_config.object_id] = true
end