Skip to content

Commit 51713cd

Browse files
twalpolep0deje
authored andcommitted
require Ruby 2.4 and use match? where appropriate
1 parent f4cd7af commit 51713cd

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed

rb/.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require:
33
- rubocop-rspec
44

55
AllCops:
6-
TargetRubyVersion: 2.3
6+
TargetRubyVersion: 2.4
77

88
Naming/RescuedExceptionsVariableName:
99
Enabled: false

rb/lib/selenium/webdriver/chrome/driver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def create_capabilities(opts)
8080
if profile
8181
profile = profile.as_json
8282

83-
options.add_argument("--user-data-dir=#{profile[:directory]}") if options.args.none? { |arg| arg =~ /user-data-dir/ }
83+
options.add_argument("--user-data-dir=#{profile[:directory]}") if options.args.none?(&/user-data-dir/.method(:match?))
8484

8585
if profile[:extensions]
8686
WebDriver.logger.deprecate 'Using Selenium::WebDriver::Chrome::Profile#extensions',

rb/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def screenshot_as(format)
5353
when :base64
5454
bridge.screenshot
5555
when :png
56-
bridge.screenshot.unpack('m')[0]
56+
bridge.screenshot.unpack1('m')
5757
else
5858
raise Error::UnsupportedOperationError, "unsupported format: #{format.inspect}"
5959
end

rb/lib/selenium/webdriver/firefox/binary.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def windows_registry_path
9696
lm = Win32::Registry::HKEY_LOCAL_MACHINE
9797
lm.open('SOFTWARE\\Mozilla\\Mozilla Firefox') do |reg|
9898
main = lm.open("SOFTWARE\\Mozilla\\Mozilla Firefox\\#{reg.keys[0]}\\Main")
99-
entry = main.find { |key, _type, _data| key =~ /pathtoexe/i }
99+
entry = main.find { |key, _type, _data| /pathtoexe/i.match? key }
100100
return entry.last if entry
101101
end
102102
rescue LoadError

rb/lib/selenium/webdriver/firefox/profile.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def write_prefs(prefs, path)
284284
end
285285

286286
def stringified?(str)
287-
str =~ /^".*"$/
287+
/^".*"$/.match?(str)
288288
end
289289
end # Profile
290290
end # Firefox

rb/lib/selenium/webdriver/remote/bridge.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def initialize(opts = {})
4949
end
5050

5151
uri = url.is_a?(URI) ? url : URI.parse(url)
52-
uri.path += '/' unless uri.path =~ %r{\/$}
52+
uri.path += '/' unless %r{\/$}.match?(uri.path)
5353

5454
http_client.server_url = uri
5555

@@ -682,7 +682,7 @@ def convert_locators(how, what)
682682
# @see https://mathiasbynens.be/notes/css-escapes
683683
def escape_css(string)
684684
string = string.gsub(ESCAPE_CSS_REGEXP) { |match| "\\#{match}" }
685-
string = "\\#{UNICODE_CODE_POINT + Integer(string[0])} #{string[1..-1]}" if !string.empty? && string[0] =~ /[[:digit:]]/
685+
string = "\\#{UNICODE_CODE_POINT + Integer(string[0])} #{string[1..-1]}" if !string.empty? && string[0].match?(/[[:digit:]]/)
686686

687687
string
688688
end

rb/lib/selenium/webdriver/support/select.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def find_by_text(text)
242242
xpath = ".//option[normalize-space(.) = #{Escaper.escape text}]"
243243
opts = @element.find_elements(xpath: xpath)
244244

245-
return opts unless opts.empty? && text =~ /\s+/
245+
return opts unless opts.empty? && /\s+/.match?(text)
246246

247247
longest_word = text.split(/\s+/).max_by(&:length)
248248
if longest_word.empty?

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def stop
6969

7070
def handler
7171
# can't use Platform here since it's being run as a file on Windows + IE.
72-
handlers = if RUBY_PLATFORM =~ /mswin|msys|mingw32/
72+
handlers = if RUBY_PLATFORM.match?(/mswin|msys|mingw32/)
7373
%w[mongrel webrick]
7474
else
7575
%w[thin mongrel webrick]

0 commit comments

Comments
 (0)