Class: Selenium::WebDriver::Support::Guards
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Inherits: | Object |
Defined in: | rb/lib/selenium/webdriver/support/guards.rb, rb/lib/selenium/webdriver/support/guards/guard.rb, rb/lib/selenium/webdriver/support/guards/guard_condition.rb |
Constant Summary
-
GUARD_TYPES =
# File 'rb/lib/selenium/webdriver/support/guards.rb', line 27%i[except only exclude exclusive flaky].freeze
Class Method Summary
Instance Attribute Summary
- #bug_tracker rw
- #messages readonly
Instance Method Summary
Constructor Details
.new(example, bug_tracker: '', conditions: nil) ⇒ Guards
# File 'rb/lib/selenium/webdriver/support/guards.rb', line 32
def initialize(example, bug_tracker: '', conditions: nil) @example = example @bug_tracker = bug_tracker @guard_conditions = conditions || [] @guards = collect_example_guards @messages = {} end
Instance Attribute Details
#bug_tracker (rw)
[ GitHub ]# File 'rb/lib/selenium/webdriver/support/guards.rb', line 30
attr_accessor :bug_tracker
#messages (readonly)
[ GitHub ]# File 'rb/lib/selenium/webdriver/support/guards.rb', line 29
attr_reader :
Instance Method Details
#add_condition(name, condition = nil)
[ GitHub ]# File 'rb/lib/selenium/webdriver/support/guards.rb', line 40
def add_condition(name, condition = nil, &) @guard_conditions << GuardCondition.new(name, condition, &) end
#add_message(name, message)
[ GitHub ]# File 'rb/lib/selenium/webdriver/support/guards.rb', line 44
def (name, ) @messages[name] = end
#collect_example_guards (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/support/guards.rb', line 64
def collect_example_guards guards = [] GUARD_TYPES.each do |guard_type| example_group = @example. [:example_group] example_guards = [@example. [guard_type], example_group[guard_type]] while example_group[:parent_example_group] example_group = example_group[:parent_example_group] example_guards << example_group[guard_type] end example_guards.flatten.uniq.compact.each do |example_guard| guards << Guard.new(example_guard, guard_type, self) end end guards end
#disposition
[ GitHub ]# File 'rb/lib/selenium/webdriver/support/guards.rb', line 48
def disposition if !skipping_guard.nil? [:skip, skipping_guard. ] elsif !pending_guard.nil? && ENV.fetch('SKIP_PENDING', nil) [:skip, pending_guard. ] elsif !pending_guard.nil? [:pending, pending_guard. ] end end
#pending_guard (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/support/guards.rb', line 88
def pending_guard @guards.select(&:except?).find { |guard| satisfied?(guard) } || @guards.select(&:only?).find { |guard| !satisfied?(guard) } end
#satisfied?(guard) ⇒ Boolean
# File 'rb/lib/selenium/webdriver/support/guards.rb', line 58
def satisfied?(guard) @guard_conditions.all? { |condition| condition.satisfied?(guard) } end
#skipping_guard (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/support/guards.rb', line 83
def skipping_guard @guards.select(&:exclusive?).find { |guard| !satisfied?(guard) } || @guards.select(&:exclude?).find { |guard| satisfied?(guard) } end