class Selenium::WebDriver::Support::Guards
def add_condition(name, condition = nil, &blk)
def add_condition(name, condition = nil, &blk) @guard_conditions << GuardCondition.new(name, condition, &blk) end
def add_message(name, message)
def add_message(name, message) @messages[name] = message end
def collect_example_guards
def collect_example_guards guards = [] GUARD_TYPES.each do |guard_type| example_group = @example.metadata[:example_group] example_guards = [@example.metadata[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
def disposition
def disposition if !skipping_guard.nil? [:skip, skipping_guard.message] elsif !pending_guard.nil? && ENV.fetch('SKIP_PENDING', nil) [:skip, pending_guard.message] elsif !pending_guard.nil? [:pending, pending_guard.message] end end
def initialize(example, bug_tracker: '', conditions: nil)
def initialize(example, bug_tracker: '', conditions: nil) @example = example @bug_tracker = bug_tracker @guard_conditions = conditions || [] @guards = collect_example_guards @messages = {} end
def pending_guard
def pending_guard @guards.select(&:except?).find { |guard| satisfied?(guard) } || @guards.select(&:only?).find { |guard| !satisfied?(guard) } end
def satisfied?(guard)
def satisfied?(guard) @guard_conditions.all? { |condition| condition.satisfied?(guard) } end
def skipping_guard
def skipping_guard @guards.select(&:exclusive?).find { |guard| !satisfied?(guard) } || @guards.select(&:exclude?).find { |guard| satisfied?(guard) } end