Skip to content

Commit

Permalink
[rb] update to latest rubocop and fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Aug 4, 2022
1 parent 994ab87 commit 4362aa1
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 20 deletions.
18 changes: 17 additions & 1 deletion rb/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,22 @@ RSpec/VerifiedDoubleReference: # new in 2.10.0
RSpec/FactoryBot/SyntaxMethods: # new in 2.7
Enabled: true
RSpec/Rails/AvoidSetupHook: # new in 2.4
Enabled: true
Enabled: false
Style/EnvHome: # new in 1.29
Enabled: true
Layout/LineContinuationLeadingSpace: # new in 1.31
Enabled: true
Layout/LineContinuationSpacing: # new in 1.31
Enabled: true
Lint/ConstantOverwrittenInRescue: # new in 1.31
Enabled: true
Lint/NonAtomicFileOperation: # new in 1.31
Enabled: true
Style/MapCompactWithConditionalBlock: # new in 1.30
Enabled: true
RSpec/ChangeByZero: # new in 2.11.0
Enabled: true
RSpec/Capybara/SpecificMatcher: # new in 2.12
Enabled: false
RSpec/Rails/HaveHttpStatus: # new in 2.12
Enabled: false
2 changes: 1 addition & 1 deletion rb/lib/selenium/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def download(required_version = :latest)
download_server(redirected, destination)
end
rescue StandardError
FileUtils.rm download_file_name if File.exist? download_file_name
FileUtils.rm_rf download_file_name
raise
end

Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/common/takes_screenshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module TakesScreenshot
def save_screenshot(png_path, full_page: false)
extension = File.extname(png_path).downcase
if extension != '.png'
WebDriver.logger.warn "name used for saved screenshot does not match file type. "\
WebDriver.logger.warn "name used for saved screenshot does not match file type. " \
"It should end with .png extension",
id: :screenshot
end
Expand Down
12 changes: 6 additions & 6 deletions rb/lib/selenium/webdriver/common/window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def initialize(bridge)

def size=(dimension)
unless dimension.respond_to?(:width) && dimension.respond_to?(:height)
raise ArgumentError, "expected #{dimension.inspect}:#{dimension.class}" \
' to respond to #width and #height'
raise ArgumentError, "expected #{dimension.inspect}:#{dimension.class} " \
'to respond to #width and #height'
end

@bridge.resize_window dimension.width, dimension.height
Expand All @@ -61,8 +61,8 @@ def size

def position=(point)
unless point.respond_to?(:x) && point.respond_to?(:y)
raise ArgumentError, "expected #{point.inspect}:#{point.class}" \
' to respond to #x and #y'
raise ArgumentError, "expected #{point.inspect}:#{point.class} " \
'to respond to #x and #y'
end

@bridge.reposition_window point.x, point.y
Expand All @@ -86,8 +86,8 @@ def position

def rect=(rectangle)
unless %w[x y width height].all? { |val| rectangle.respond_to? val }
raise ArgumentError, "expected #{rectangle.inspect}:#{rectangle.class}" \
' to respond to #x, #y, #width, and #height'
raise ArgumentError, "expected #{rectangle.inspect}:#{rectangle.class} " \
'to respond to #x, #y, #width, and #height'
end

@bridge.set_window_rect(x: rectangle.x,
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/common/zipper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def unzip(path)
to = File.join(destination, entry.name)
dirname = File.dirname(to)

FileUtils.mkdir_p dirname unless File.exist? dirname
FileUtils.mkdir_p dirname
zip.extract(entry, to)
end
end
Expand Down
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/remote/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ def clear_element(element)

def submit_element(element)
script = "var form = arguments[0];\n" \
"while (form.nodeName != \"FORM\" && form.parentNode) {\n" \
" form = form.parentNode;\n" \
"while (form.nodeName != \"FORM\" && form.parentNode) {\n " \
"form = form.parentNode;\n" \
"}\n" \
"if (!form) { throw Error('Unable to find containing form element'); }\n" \
"if (!form.ownerDocument) { throw Error('Unable to find owning document'); }\n" \
Expand Down
6 changes: 3 additions & 3 deletions rb/selenium-webdriver.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rack', ['~> 2.0']
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec', ['~> 3.0']
s.add_development_dependency 'rubocop', ['~> 1.22']
s.add_development_dependency 'rubocop-performance'
s.add_development_dependency 'rubocop', ['~> 1.31']
s.add_development_dependency 'rubocop-performance', ['~> 1.13']
s.add_development_dependency 'rubocop-rake'
s.add_development_dependency 'rubocop-rspec'
s.add_development_dependency 'rubocop-rspec', ['~> 2.12']
s.add_development_dependency 'webmock', ['~> 3.5']
s.add_development_dependency 'webrick', ['~> 1.7']
s.add_development_dependency 'yard', ['~> 0.9.11']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module Chrome
expect(File.exist?(path)).to be true
expect(File.size(path)).to be_positive
ensure
File.delete(path) if File.exist?(path)
FileUtils.rm_rf(path)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module Firefox
end

ensure
File.delete(path) if File.exist?(path)
FileUtils.rm_rf(path)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module WebDriver

it 'should warn if extension of provided path is not png' do
jpg_path = "#{Dir.tmpdir}/test#{SecureRandom.urlsafe_base64}.jpg"
message = "name used for saved screenshot does not match file type. "\
message = "name used for saved screenshot does not match file type. " \
"It should end with .png extension"
expect(WebDriver.logger).to receive(:warn).with(message, id: :screenshot).twice

Expand Down Expand Up @@ -68,7 +68,7 @@ def save_screenshot_and_assert(source, path)
expect(File.exist?(path)).to be true
expect(File.size(path)).to be_positive
ensure
File.delete(path) if File.exist?(path)
FileUtils.rm_rf(path)
end

describe 'page size' do
Expand All @@ -77,7 +77,7 @@ def save_screenshot_and_assert(source, path)
end

after do
File.delete(path) if File.exist?(path)
FileUtils.rm_rf(path)
end

it 'takes viewport screenshot by default' do
Expand Down

0 comments on commit 4362aa1

Please sign in to comment.