Class: RSpec::Undefined::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/undefined/configuration.rb

Constant Summary collapse

ALLOWED_FORMATS =
[:json, :yaml, :markdown].freeze
TRUE_VALUES =
%w[1 true yes].freeze

Instance Method Summary collapse

Constructor Details

#initialize(env: ENV) ⇒ Configuration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
# File 'lib/rspec/undefined/configuration.rb', line 9

def initialize(env: ENV)
  @env = env
  @strict_explicit = nil
  @report_path = nil
  @report_format = :json
  @mutex = Mutex.new
end

Instance Method Details

#register_categories(*names) ⇒ Object



49
50
51
52
# File 'lib/rspec/undefined/configuration.rb', line 49

def register_categories(*names)
  require "rspec/undefined/categories"
  Categories.register(*names)
end

#report_formatObject



37
38
39
# File 'lib/rspec/undefined/configuration.rb', line 37

def report_format
  @mutex.synchronize { @report_format }
end

#report_format=(value) ⇒ Object



30
31
32
33
34
35
# File 'lib/rspec/undefined/configuration.rb', line 30

def report_format=(value)
  unless ALLOWED_FORMATS.include?(value)
    raise ArgumentError, "report_format must be one of #{ALLOWED_FORMATS.inspect}"
  end
  @mutex.synchronize { @report_format = value }
end

#report_pathObject



41
42
43
# File 'lib/rspec/undefined/configuration.rb', line 41

def report_path
  @mutex.synchronize { @report_path }
end

#report_path=(value) ⇒ Object



45
46
47
# File 'lib/rspec/undefined/configuration.rb', line 45

def report_path=(value)
  @mutex.synchronize { @report_path = value }
end

#strict=(value) ⇒ Object



26
27
28
# File 'lib/rspec/undefined/configuration.rb', line 26

def strict=(value)
  @mutex.synchronize { @strict_explicit = value ? true : false }
end

#strict?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
# File 'lib/rspec/undefined/configuration.rb', line 17

def strict?
  @mutex.synchronize do
    return @strict_explicit unless @strict_explicit.nil?
    v = @env["RSPEC_UNDEFINED_STRICT"]
    return false if v.nil?
    TRUE_VALUES.include?(v.downcase)
  end
end