Skip to content

Commit

Permalink
[rb] implement spec guard for exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Nov 17, 2017
1 parent 937cf56 commit 036fcaa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion rb/spec/integration/selenium/webdriver/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@

c.before do |example|
guards = WebDriver::SpecSupport::Guards.new(example)
if guards.except.satisfied.any? || guards.only.unsatisfied.any?
if guards.exclude.any?
skip 'Bug Prevents Execution.'
elsif guards.except.satisfied.any? || guards.only.unsatisfied.any?
pending 'Guarded.'
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module SpecSupport
class Guards
include Enumerable

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

def initialize(example, guards = nil)
@example = example
Expand All @@ -40,6 +40,10 @@ def only
self.class.new(@example, @guards.select(&:only?))
end

def exclude
self.class.new(@example, @guards.select(&:exclude?)).satisfied
end

def satisfied
self.class.new(@example, @guards.select(&:satisfied?))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def only?
@type == :only
end

def exclude?
@type == :exclude
end

def satisfied?
satisfies_driver? && satisfies_browser? && satisfies_platform? && satisfies_window_manager?
end
Expand Down

0 comments on commit 036fcaa

Please sign in to comment.