Class: Evilution::Runner::IsolationResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/evilution/runner/isolation_resolver.rb

Constant Summary collapse

PRELOAD_CANDIDATES =
[
  File.join("spec", "rails_helper.rb"),
  File.join("spec", "spec_helper.rb"),
  File.join("test", "test_helper.rb")
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(config, target_files:, hooks:) ⇒ IsolationResolver

Returns a new instance of IsolationResolver.



16
17
18
19
20
# File 'lib/evilution/runner/isolation_resolver.rb', line 16

def initialize(config, target_files:, hooks:)
  @config = config
  @target_files_callback = target_files
  @hooks = hooks
end

Instance Method Details

#isolatorObject



22
23
24
# File 'lib/evilution/runner/isolation_resolver.rb', line 22

def isolator
  @isolator ||= build_isolator
end

#perform_preloadObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/evilution/runner/isolation_resolver.rb', line 32

def perform_preload
  return if config.preload == false
  return unless should_preload?

  path = resolve_preload_path
  return unless path

  prepare_load_path_for_preload
  require File.expand_path(path)
rescue Evilution::ConfigError
  raise
rescue ScriptError, StandardError => e
  raise Evilution::ConfigError.new(
    "failed to preload #{path.inspect}: #{e.class}: #{e.message}",
    file: path
  )
end

#rails_root_detected?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
# File 'lib/evilution/runner/isolation_resolver.rb', line 26

def rails_root_detected?
  return @rails_root_detected if defined?(@rails_root_detected)

  @rails_root_detected = !detected_rails_root.nil?
end