Class: RSpec::Hermetic::Allowlist

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/hermetic/allowlist.rb,
sig/rspec/hermetic.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAllowlist

Returns a new instance of Allowlist.



10
11
12
13
14
15
# File 'lib/rspec/hermetic/allowlist.rb', line 10

def initialize
  @env_patterns = []
  @path_patterns = []
  @constant_patterns = []
  @append_only_patterns = []
end

Instance Attribute Details

#append_only_patternsObject (readonly)

Returns the value of attribute append_only_patterns.



8
9
10
# File 'lib/rspec/hermetic/allowlist.rb', line 8

def append_only_patterns
  @append_only_patterns
end

#constant_patternsObject (readonly)

Returns the value of attribute constant_patterns.



8
9
10
# File 'lib/rspec/hermetic/allowlist.rb', line 8

def constant_patterns
  @constant_patterns
end

#env_patternsObject (readonly)

Returns the value of attribute env_patterns.



8
9
10
# File 'lib/rspec/hermetic/allowlist.rb', line 8

def env_patterns
  @env_patterns
end

#path_patternsObject (readonly)

Returns the value of attribute path_patterns.



8
9
10
# File 'lib/rspec/hermetic/allowlist.rb', line 8

def path_patterns
  @path_patterns
end

Instance Method Details

#allowed?(change, example_allowances) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
# File 'lib/rspec/hermetic/allowlist.rb', line 33

def allowed?(change, example_allowances)
  allowed_by_metadata?(change, example_allowances) ||
    allowed_env?(change) ||
    allowed_path?(change) ||
    allowed_constant?(change)
end

#append_only(*patterns) ⇒ Object

Parameters:

  • patterns (Object)

Returns:

  • (Object)


29
30
31
# File 'lib/rspec/hermetic/allowlist.rb', line 29

def append_only(*patterns)
  @append_only_patterns.concat(patterns)
end

#append_only?(change) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/rspec/hermetic/allowlist.rb', line 40

def append_only?(change)
  pattern_match?(append_only_patterns, change.key.to_s)
end

#constant(*patterns) ⇒ Object

Parameters:

  • patterns (Object)

Returns:

  • (Object)


25
26
27
# File 'lib/rspec/hermetic/allowlist.rb', line 25

def constant(*patterns)
  @constant_patterns.concat(patterns)
end

#env(*patterns) ⇒ Object

Parameters:

  • patterns (Object)

Returns:

  • (Object)


17
18
19
# File 'lib/rspec/hermetic/allowlist.rb', line 17

def env(*patterns)
  @env_patterns.concat(patterns)
end

#path(*patterns) ⇒ Object

Parameters:

  • patterns (Object)

Returns:

  • (Object)


21
22
23
# File 'lib/rspec/hermetic/allowlist.rb', line 21

def path(*patterns)
  @path_patterns.concat(patterns)
end