Class: RSpec::Hermetic::Allowlist
- Inherits:
-
Object
- Object
- RSpec::Hermetic::Allowlist
- Defined in:
- lib/rspec/hermetic/allowlist.rb,
sig/rspec/hermetic.rbs
Instance Attribute Summary collapse
-
#append_only_patterns ⇒ Object
readonly
Returns the value of attribute append_only_patterns.
-
#constant_patterns ⇒ Object
readonly
Returns the value of attribute constant_patterns.
-
#env_patterns ⇒ Object
readonly
Returns the value of attribute env_patterns.
-
#path_patterns ⇒ Object
readonly
Returns the value of attribute path_patterns.
Instance Method Summary collapse
- #allowed?(change, example_allowances) ⇒ Boolean
- #append_only(*patterns) ⇒ Object
- #append_only?(change) ⇒ Boolean
- #constant(*patterns) ⇒ Object
- #env(*patterns) ⇒ Object
-
#initialize ⇒ Allowlist
constructor
A new instance of Allowlist.
- #path(*patterns) ⇒ Object
Constructor Details
#initialize ⇒ Allowlist
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_patterns ⇒ Object (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_patterns ⇒ Object (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_patterns ⇒ Object (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_patterns ⇒ Object (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
33 34 35 36 37 38 |
# File 'lib/rspec/hermetic/allowlist.rb', line 33 def allowed?(change, example_allowances) (change, example_allowances) || allowed_env?(change) || allowed_path?(change) || allowed_constant?(change) end |
#append_only(*patterns) ⇒ 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
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
25 26 27 |
# File 'lib/rspec/hermetic/allowlist.rb', line 25 def constant(*patterns) @constant_patterns.concat(patterns) end |
#env(*patterns) ⇒ Object
17 18 19 |
# File 'lib/rspec/hermetic/allowlist.rb', line 17 def env(*patterns) @env_patterns.concat(patterns) end |
#path(*patterns) ⇒ Object
21 22 23 |
# File 'lib/rspec/hermetic/allowlist.rb', line 21 def path(*patterns) @path_patterns.concat(patterns) end |