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
GEM_PRELOAD_CANDIDATES =

Conventional helpers for a non-Rails gem (no rails_helper). Ordered rspec then minitest/test-unit; test/helper.rb covers the flat-layout convention (rack, connection_pool, rake).

[
  File.join("spec", "spec_helper.rb"),
  File.join("test", "test_helper.rb"),
  File.join("test", "helper.rb")
].freeze

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of IsolationResolver.



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

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

Instance Method Details

#isolatorObject



31
32
33
# File 'lib/evilution/runner/isolation_resolver.rb', line 31

def isolator
  @isolator ||= build_isolator
end

#perform_preloadObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/evilution/runner/isolation_resolver.rb', line 41

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

  path = resolve_preload_path
  return unless path

  prepare_load_path_for_preload(path)
  prepare_integration_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)


35
36
37
38
39
# File 'lib/evilution/runner/isolation_resolver.rb', line 35

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

  @rails_root_detected = !detected_rails_root.nil?
end