Class: RSpecTracer::RemoteCache::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_tracer/remote_cache/validator.rb

Defined Under Namespace

Classes: ValidationError

Constant Summary collapse

CACHE_FILES_PER_TEST_SUITE =
11

Instance Method Summary collapse

Constructor Details

#initializeValidator

Returns a new instance of Validator.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rspec_tracer/remote_cache/validator.rb', line 10

def initialize
  @test_suite_id = ENV.fetch('TEST_SUITE_ID', nil)
  @test_suites = ENV.fetch('TEST_SUITES', nil)
  @use_test_suite_id_cache = ENV.fetch('USE_TEST_SUITE_ID_CACHE', nil) == 'true'

  if @test_suite_id.nil? ^ @test_suites.nil?
    raise(
      ValidationError,
      'Both the environment variables TEST_SUITE_ID and TEST_SUITES are not set'
    )
  end

  setup
end

Instance Method Details

#valid?(ref, cache_files) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
# File 'lib/rspec_tracer/remote_cache/validator.rb', line 25

def valid?(ref, cache_files)
  if @use_test_suite_id_cache
    test_suite_id_specific_validation?(ref, cache_files)
  else
    general_validation?(ref, cache_files)
  end
end