Skip to content

Commit

Permalink
Merge branch 'trunk' into bazel_bidi_flag
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner authored Jun 5, 2024
2 parents 3a769e1 + e98cc84 commit e153eb5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
17 changes: 8 additions & 9 deletions rb/lib/selenium/webdriver/support/guards/guard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Guards
#

class Guard
attr_reader :guarded, :type, :messages, :reason
attr_reader :guarded, :type, :messages, :reason, :tracker

def initialize(guarded, type, guards = nil)
@guarded = guarded
Expand All @@ -36,22 +36,21 @@ def initialize(guarded, type, guards = nil)
@messages[:unknown] = 'TODO: Investigate why this is failing and file a bug report'
@type = type

@reason = @guarded.delete(:reason)
@reason = @guarded[:reason] || 'No reason given'
@guarded[:reason] = @reason
end

def message
details = case @reason
details = case reason
when Integer
"Bug Filed: #{@tracker}/#{@reason}"
"Bug Filed: #{tracker}/#{reason}"
when Symbol
@messages[@reason]
when String
@reason
messages[reason]
else
'no reason given'
"Guarded by #{guarded};"
end

case @type
case type
when :exclude
"Test skipped because it breaks test run; #{details}"
when :flaky
Expand Down
17 changes: 9 additions & 8 deletions rb/spec/unit/selenium/webdriver/guard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ module Support
guards = described_class.new(example)
guards.add_condition(:foo, false)

expect(guards.disposition).to eq [:pending, 'Test guarded; no reason given']
expect(guards.disposition).to eq [:pending, 'Test guarded; Guarded by {:foo=>false, :reason=>"No reason given"};']
end

it 'is skipped without provided reason', exclusive: {foo: true} do |example|
guards = described_class.new(example)
guards.add_condition(:foo, false)

message = 'Test does not apply to this configuration; no reason given'
message = 'Test does not apply to this configuration; Guarded by {:foo=>true, :reason=>"No reason given"};'
expect(guards.disposition).to eq [:skip, message]
end
end
Expand Down Expand Up @@ -138,7 +138,7 @@ module Support
describe '#new' do
it 'requires guarded Hash and type' do
guard = described_class.new({foo: 7}, :only)
expect(guard.guarded).to eq(foo: 7)
expect(guard.guarded).to eq(foo: 7, reason: 'No reason given')
expect(guard.type).to eq :only
end

Expand All @@ -157,7 +157,7 @@ module Support
it 'defaults to no reason given' do
guard = described_class.new({}, :only)

expect(guard.message).to eq('Test guarded; no reason given')
expect(guard.message).to eq('Test guarded; Guarded by {:reason=>"No reason given"};')
end

it 'accepts integer' do |example|
Expand All @@ -170,7 +170,7 @@ module Support
it 'accepts String' do
guard = described_class.new({reason: 'because'}, :only)

expect(guard.message).to eq('Test guarded; because')
expect(guard.message).to eq('Test guarded; Guarded by {:reason=>"because"};')
end

it 'accepts Symbol of known message' do
Expand All @@ -190,19 +190,20 @@ module Support
it 'has special message for exclude' do
guard = described_class.new({reason: 'because'}, :exclude)

expect(guard.message).to eq('Test skipped because it breaks test run; because')
expect(guard.message).to eq('Test skipped because it breaks test run; Guarded by {:reason=>"because"};')
end

it 'has special message for flaky' do
guard = described_class.new({reason: 'because'}, :flaky)

expect(guard.message).to eq('Test skipped because it is unreliable in this configuration; because')
msg = 'Test skipped because it is unreliable in this configuration; Guarded by {:reason=>"because"};'
expect(guard.message).to eq(msg)
end

it 'has special message for exclusive' do
guard = described_class.new({reason: 'because'}, :exclusive)

expect(guard.message).to eq('Test does not apply to this configuration; because')
expect(guard.message).to eq('Test does not apply to this configuration; Guarded by {:reason=>"because"};')
end
end
end
Expand Down

0 comments on commit e153eb5

Please sign in to comment.