Skip to content

Commit d185307

Browse files
authored
fix Minitest::VERSION error (#751)
* fix Minitest::VERSION error * arrange comments
1 parent 7b72377 commit d185307

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

lib/appium_lib/driver.rb

+27-22
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
# Fix uninitialized constant Minitest (NameError)
2-
module Minitest
3-
# Fix superclass mismatch for class Spec
4-
class Runnable
5-
end
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
1+
# Load only Minitest is loaded
2+
if defined?(Minitest::VERSION)
3+
# Fix uninitialized constant Minitest (NameError)
4+
module Minitest
5+
# Fix superclass mismatch for class Spec
6+
class Runnable
7+
end
8+
9+
# defined? 'Minitest' # expression
10+
11+
# To switch load class
12+
def self.left_greater_than_or_equal_to_right?(left, right)
13+
left.split('.').zip(right.split('.')).each do |value|
14+
diff = value[0].to_i - value[1].to_i
15+
return true if diff > 0
16+
return false if diff < 0
17+
end
18+
true
1319
end
14-
true
15-
end
1620

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+
if left_greater_than_or_equal_to_right?(VERSION, '5.11.0')
22+
# http://docs.seattlerb.org/minitest/History_rdoc.html#label-5.11.0+-2F+2018-01-01
23+
# `Minitest::Test` became a subclass of `Minitest::Result`
24+
class Test < Result
25+
end
26+
else
27+
class Test < Runnable
28+
end
2129
end
22-
else
23-
class Test < Runnable
30+
class Spec < Test
2431
end
2532
end
26-
class Spec < Test
27-
end
2833
end
2934

3035
require 'appium_lib_core'

0 commit comments

Comments
 (0)