Skip to content

Commit eeea236

Browse files
authored
fix: add condition flow for minitest (#748)
* add condition flow * add comments * add changelog * add test cases
1 parent 5de0bec commit eeea236

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Release tags are https://github.com/appium/ruby_lib/releases .
77
### 1. Enhancements
88

99
### 2. Bug fixes
10+
- Fix `TypeError: superclass mismatch for class Test` for minitest `5.11.0`+ [PR](https://github.com/appium/ruby_lib/pull/748)
1011

1112
### 3. Deprecations
1213

ios_tests/lib/ios/specs/driver.rb

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ def sauce?
1212
ENV['UPLOAD_FILE'] && ENV['SAUCE_USERNAME']
1313
end
1414

15+
t 'left_greater_than_or_equal_to_right?' do
16+
assert Minitest.left_greater_than_or_equal_to_right? '5.11.1', '5.11.0'
17+
assert Minitest.left_greater_than_or_equal_to_right? '5.11.0', '5.11.0'
18+
assert !Minitest.left_greater_than_or_equal_to_right?('5.10.1', '5.11.0')
19+
assert !Minitest.left_greater_than_or_equal_to_right?('5.10.0', '5.11.0')
20+
assert !Minitest.left_greater_than_or_equal_to_right?('4.10.0', '5.11.0')
21+
end
22+
1523
t 'unicode defaults' do
1624
data = File.read File.expand_path '../../../../data/unicode.txt', __FILE__
1725
data.strip.must_equal 174.chr('UTF-8')

lib/appium_lib/driver.rb

+19-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,25 @@ module Minitest
33
# Fix superclass mismatch for class Spec
44
class Runnable
55
end
6-
class Test < Runnable
6+
7+
# To switch load class
8+
def self.left_greater_than_or_equal_to_right?(left, right)
9+
left.split('.').zip(right.split('.')).each do |value|
10+
diff = value[0].to_i - value[1].to_i
11+
return true if diff > 0
12+
return false if diff < 0
13+
end
14+
true
15+
end
16+
17+
if left_greater_than_or_equal_to_right?(VERSION, '5.11.0')
18+
# http://docs.seattlerb.org/minitest/History_rdoc.html#label-5.11.0+-2F+2018-01-01
19+
# `Minitest::Test` became a subclass of `Minitest::Result`
20+
class Test < Result
21+
end
22+
else
23+
class Test < Runnable
24+
end
725
end
826
class Spec < Test
927
end

0 commit comments

Comments
 (0)