Class: Selenium::WebDriver::Support::Guards

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/support/guards.rb,
lib/selenium/webdriver/support/guards/guard.rb,
lib/selenium/webdriver/support/guards/guard_condition.rb

Defined Under Namespace

Classes: Guard, GuardCondition

Constant Summary collapse

GUARD_TYPES =
%i[except only exclude exclusive flaky].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(example, bug_tracker: '', conditions: nil) ⇒ Guards

Returns a new instance of Guards.



32
33
34
35
36
37
38
# File '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_trackerObject

Returns the value of attribute bug_tracker.



30
31
32
# File 'lib/selenium/webdriver/support/guards.rb', line 30

def bug_tracker
  @bug_tracker
end

#messagesObject (readonly)

Returns the value of attribute messages.



29
30
31
# File 'lib/selenium/webdriver/support/guards.rb', line 29

def messages
  @messages
end

Instance Method Details

#add_condition(name, condition = nil) ⇒ Object



40
41
42
# File '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) ⇒ Object



44
45
46
# File 'lib/selenium/webdriver/support/guards.rb', line 44

def add_message(name, message)
  @messages[name] = message
end

#dispositionObject



48
49
50
51
52
53
54
55
56
# File 'lib/selenium/webdriver/support/guards.rb', line 48

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

#satisfied?(guard) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/selenium/webdriver/support/guards.rb', line 58

def satisfied?(guard)
  @guard_conditions.all? { |condition| condition.satisfied?(guard) }
end