Module: RSpecTracer::Configuration

Included in:
RSpecTracer
Defined in:
lib/rspec_tracer/configuration.rb

Defined Under Namespace

Classes: InvalidUsageError

Constant Summary collapse

ALLOWED_CONFIGURER =
%w[
  lib/rspec_tracer/load_default_config.rb
  lib/rspec_tracer/load_global_config.rb
  lib/rspec_tracer/load_local_config.rb
].freeze
DEFAULT_CACHE_DIR =
'rspec_tracer_cache'
DEFAULT_COVERAGE_DIR =
'rspec_tracer_coverage'
DEFAULT_REPORT_DIR =
'rspec_tracer_report'
DEFAULT_LOCK_FILE =
'rspec_tracer.lock'
LOG_LEVEL =
{
  off: 0,
  debug: 1,
  info: 2,
  warn: 3,
  error: 4
}.freeze

Instance Method Summary collapse

Instance Method Details

#configureObject

Raises:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rspec_tracer/configuration.rb', line 29

def configure(&)
  configurers = caller_locations(1, 2).map(&:path)
  invalid = configurers.none? do |configurer|
    ALLOWED_CONFIGURER.any? do |allowed_configurer|
      configurer.end_with?(allowed_configurer)
    end
  end

  raise InvalidUsageError, 'You must define configurations in a .rspec-tracer file' if invalid

  RSpecTracer::Configuration.module_exec do
    RSpecTracer::Configuration.private_instance_methods(false).each do |method_name|
      alias_method :"_#{method_name}", method_name

      define_method method_name do |*args, &block|
        send(:"_#{method_name}", *args, &block)
      end
    end
  end

  Docile.dsl_eval(self, &)
end