Class: Selenium::WebDriver::Support::Guards::Guard Private
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Support::Guards::Guard
- Defined in:
- lib/selenium/webdriver/support/guards/guard.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Guard derived from RSpec example metadata.
Instance Attribute Summary collapse
- #guarded ⇒ Object readonly private
- #messages ⇒ Object readonly private
- #reason ⇒ Object readonly private
- #tracker ⇒ Object readonly private
- #type ⇒ Object readonly private
Instance Method Summary collapse
-
#except? ⇒ Boolean
private
Test is expected to fail on the configurations specified (marked pending).
-
#exception? ⇒ Boolean
private
A pending guard that only applies when the failure matches an expected exception.
-
#exclude? ⇒ Boolean
private
Test is skipped on the configurations specified because it breaks the run or is unreliable.
-
#exclusive? ⇒ Boolean
private
Test is skipped on every configuration except those specified (it only applies there).
-
#initialize(guarded, type, guards = nil) ⇒ Guard
constructor
private
A new instance of Guard.
-
#matches_exception?(exception) ⇒ Boolean
private
Whether the exception is the guard's
exception:class and matches its optionalmessage:(Regexp pattern or exact String), following RSpec'sraise_errorsemantics. - #message ⇒ Object private
-
#only? ⇒ Boolean
private
Test is expected to fail on every configuration except those specified (marked pending).
Constructor Details
#initialize(guarded, type, guards = nil) ⇒ Guard
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Guard.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 32 def initialize(guarded, type, guards = nil) @guarded = guarded.dup @tracker = guards&.bug_tracker || '' @messages = guards&. || {} @messages[:unknown] = 'TODO: Investigate why this is failing and file a bug report' @type = type @reason = @guarded[:reason] || 'No reason given' @guarded[:reason] = @reason end |
Instance Attribute Details
#guarded ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 30 def guarded @guarded end |
#messages ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 30 def @messages end |
#reason ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 30 def reason @reason end |
#tracker ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 30 def tracker @tracker end |
#type ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 30 def type @type end |
Instance Method Details
#except? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Test is expected to fail on the configurations specified (marked pending).
68 69 70 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 68 def except? @type == :pending_if || @type == :except end |
#exception? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
A pending guard that only applies when the failure matches an expected exception.
88 89 90 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 88 def exception? (except? || only?) && !@guarded[:exception].nil? end |
#exclude? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Test is skipped on the configurations specified because it breaks the run or is unreliable.
78 79 80 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 78 def exclude? @type == :skip_if || @type == :exclude || @type == :flaky end |
#exclusive? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Test is skipped on every configuration except those specified (it only applies there).
83 84 85 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 83 def exclusive? @type == :skip_unless || @type == :exclusive end |
#matches_exception?(exception) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Whether the exception is the guard's exception: class and matches its optional message:
(Regexp pattern or exact String), following RSpec's raise_error semantics.
94 95 96 97 98 99 100 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 94 def matches_exception?(exception) spec = @guarded[:exception] return false unless spec && exception.is_a?(spec[:class]) = spec[:message] .nil? || (.is_a?(Regexp) ? .match?(exception.) : == exception.) end |
#message ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 43 def details = case reason when Integer "Bug Filed: #{tracker}/#{reason}" when Symbol [reason] else "#{type.to_s.tr('_', ' ')} #{guarded};" end case type when :skip_if, :exclude "Test skipped because it breaks test run; #{details}" when :flaky "Test skipped because it is unreliable in this configuration; #{details}" when :skip_unless, :exclusive "Test does not apply to this configuration; #{details}" when :pending_if, :pending_unless, :except, :only "Test guarded; #{details}" else raise ArgumentError, "unknown guard type: #{type}" end end |
#only? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Test is expected to fail on every configuration except those specified (marked pending).
73 74 75 |
# File 'lib/selenium/webdriver/support/guards/guard.rb', line 73 def only? @type == :pending_unless || @type == :only end |