Skip to content

Commit 42f01dd

Browse files
authored
feat: bump ruby version (#887)
* feat: bump ruby version * relevant changes
1 parent dc228b3 commit 42f01dd

File tree

11 files changed

+20
-22
lines changed

11 files changed

+20
-22
lines changed

.github/workflows/rubocop.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
ruby: [2.2, 2.3, 2.4, 2.5, 2.6, 2.7]
14+
ruby: [2.4, 2.5, 2.6, 2.7]
1515

1616
runs-on: ubuntu-latest
1717

.rubocop.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AllCops:
2-
TargetRubyVersion: 2.3
2+
TargetRubyVersion: 2.4
33
Metrics/LineLength:
44
Max: 128
55
Metrics/MethodLength:
@@ -25,12 +25,6 @@ Style/GlobalVars:
2525
Enabled: false
2626
Style/PercentLiteralDelimiters:
2727
Enabled: false
28-
# Can use over Ruby2.3
29-
Style/SafeNavigation:
30-
Enabled: false
31-
# Can use over Ruby2.3
32-
Style/NumericPredicate:
33-
Enabled: false
3428
Style/CommentedKeyword:
3529
Enabled: false
3630
Naming/AccessorMethodName:

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Commit based release not is [release_notes.md](./release_notes.md)
44
Release tags are https://github.com/appium/ruby_lib/releases .
55

66
## Unreleased
7+
8+
Bump supported Ruby version to 2.4+
9+
10+
[related changes](https://github.com/appium/ruby_lib_core/blob/master/CHANGELOG.md#400---2020-12-19) in ruby_lib_core.
11+
712
### 1. Enhancements
813

914
### 2. Bug fixes

android_tests/lib/run.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,6 @@ def start_driver(caps)
101101
end
102102

103103
# Exit after tests.
104-
Minitest.after_run { $driver.x if $driver }
104+
Minitest.after_run { $driver&.x }
105105
# Run Minitest. Provide test file array for tracing.
106106
Minitest.run_specs(trace: trace_files)

appium_lib.gemspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require_relative 'lib/appium_lib/version'
22

33
Gem::Specification.new do |s|
4-
s.required_ruby_version = '>= 2.2' # rubocop:disable Gemspec/RequiredRubyVersion
4+
s.required_ruby_version = '>= 2.4'
55

66
s.name = 'appium_lib'
77
s.version = Appium::VERSION
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
1414
s.homepage = 'https://github.com/appium/ruby_lib' # published as appium_lib
1515
s.require_paths = ['lib']
1616

17-
s.add_runtime_dependency 'appium_lib_core', '~> 3.3'
17+
s.add_runtime_dependency 'appium_lib_core', '~> 4.0'
1818
s.add_runtime_dependency 'nokogiri', '~> 1.8', '>= 1.8.1'
1919
s.add_runtime_dependency 'tomlrb', '~> 1.1'
2020

lib/appium_lib/android/element/button.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def last_button
6060
# uiautomator index doesn't support last
6161
# and it's 0 indexed
6262
button_index = tags(BUTTON).length
63-
button_index -= 1 if button_index > 0
63+
button_index -= 1 if button_index.positive?
6464
image_button_index = tags(IMAGE_BUTTON).length
65-
image_button_index -= 1 if image_button_index > 0
65+
image_button_index -= 1 if image_button_index.positive?
6666

6767
find_element :uiautomator,
6868
_button_visible_selectors(button_index: button_index,

lib/appium_lib/android/espresso/element/button.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def last_button
6363
# uiautomator index doesn't support last
6464
# and it's 0 indexed
6565
button_index = tags(::Appium::Android::BUTTON).length
66-
button_index -= 1 if button_index > 0
66+
button_index -= 1 if button_index.positive?
6767
image_button_index = tags(::Appium::Android::IMAGE_BUTTON).length
68-
image_button_index -= 1 if image_button_index > 0
68+
image_button_index -= 1 if image_button_index.positive?
6969

7070
_button_visible_selectors_xpath(button_index: button_index,
7171
image_button_index: image_button_index)

lib/appium_lib/android/uiautomator2/element/button.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def last_button
6060
# uiautomator index doesn't support last
6161
# and it's 0 indexed
6262
button_index = tags(::Appium::Android::Button).length
63-
button_index -= 1 if button_index > 0
63+
button_index -= 1 if button_index.positive?
6464
image_button_index = tags(::Appium::Android::ImageButton).length
65-
image_button_index -= 1 if image_button_index > 0
65+
image_button_index -= 1 if image_button_index.positive?
6666

6767
elements = find_elements :uiautomator,
6868
_button_visible_selectors(button_index: button_index,

lib/appium_lib/driver.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,8 @@ def initialize(opts = {}, global_driver = nil)
163163
global_driver = true # if global_driver is nil, then global_driver must be default value.
164164
end
165165

166-
if global_driver
167-
$driver.driver_quit if $driver
168-
end
166+
$driver&.driver_quit if global_driver
167+
169168
raise 'opts must be a hash' unless opts.is_a? Hash
170169

171170
@core = ::Appium::Core.for(opts)

lib/appium_lib/ios/common/helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def page(opts = {})
7676
source = get_source
7777

7878
# current_context may be nil which breaks start_with
79-
if current_context && current_context.start_with?('WEBVIEW')
79+
if current_context&.start_with?('WEBVIEW')
8080
parser = @android_html_parser ||= Nokogiri::HTML::SAX::Parser.new(Appium::Common::HTMLElements.new)
8181
parser.document.reset
8282
parser.document.filter = class_name

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ We can avoid the class driver with current `ruby_lib`, but if you'd like to impl
2121
# Setup
2222
## Requirement
2323
- [Appium](https://github.com/appium/appium#requirements)
24-
- Ruby: 2.2+
24+
- Ruby: 2.4+
2525

2626
### Ruby Lib and Appium
2727
- Ruby library version over `9.8.0` requires Appium over `1.8`

0 commit comments

Comments
 (0)