Class: Capybara::Storyboard::Policies::TargetListPolicy
- Inherits:
-
Object
- Object
- Capybara::Storyboard::Policies::TargetListPolicy
- Defined in:
- lib/capybara/storyboard/policies/target_list_policy.rb
Overview
Restricts screenshots to an explicit set of test files. The set holds already-normalized paths (see Capybara::Storyboard.normalize_test_path); #call normalizes the context's raw test_file the same way before matching.
An empty set means "explicitly no targets" and always returns false. The backward-compatible "capture everything" behavior is handled upstream by default_policy, which simply never constructs this policy when no target list is configured.
Instance Method Summary collapse
- #call(context) ⇒ Object
-
#initialize(paths) ⇒ TargetListPolicy
constructor
A new instance of TargetListPolicy.
Constructor Details
#initialize(paths) ⇒ TargetListPolicy
Returns a new instance of TargetListPolicy.
15 16 17 |
# File 'lib/capybara/storyboard/policies/target_list_policy.rb', line 15 def initialize(paths) @paths = Set.new(paths) end |
Instance Method Details
#call(context) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/capybara/storyboard/policies/target_list_policy.rb', line 19 def call(context) return false if @paths.empty? test_file = context&.test_file return false if test_file.nil? @paths.include?(Capybara::Storyboard.normalize_test_path(test_file)) end |