android_tests/Rakefile in appium_lib-6.0.0 vs android_tests/Rakefile in appium_lib-7.0.0

- old
+ new

@@ -1,24 +1,24 @@ require 'rubygems' require 'rake' +require 'rubocop/rake_task' -task :default => :android +task default: :android # Run sh and ignore exception -def run_sh cmd - begin - sh cmd - rescue - end +# rubocop:disable Lint/HandleExceptions +def run_sh(cmd) + sh cmd +rescue end # Run cmd. On failure run install and try again. -def bash cmd +def bash(cmd) sh cmd do |successful, result| # exitstatus 7 means bundle install failed # exitstatus 1 means the test failed - if !successful && result.exitstatus === 7 + if !successful && result.exitstatus == 7 Rake::Task['install'].execute run_sh cmd end end end @@ -31,31 +31,38 @@ end end # rake android['single_text_name'] # rake android -def run_android test_file=nil +def run_android(test_file = nil) wait_for_valid_device cmd = 'bundle exec ruby ./lib/run.rb android' - cmd += %Q( "#{test_file}") if test_file + cmd += %( "#{test_file}") if test_file bash cmd end # Run a single test with: # rake android['android/element/generic'] # # Run all tests with: # rake android desc 'Run the Android tests' -task :android, :args, :test_file do |args, test_file| +task :android, :args, :test_file do |_args, test_file| run_android test_file[:args] end desc 'Run the Android tests without uninstalling' -task :droid, :args, :test_file do |args, test_file| +task :droid, :args, :test_file do |_args, test_file| run_android test_file[:args] end desc 'Run bundle install' task :install do sh 'bundle install' -end \ No newline at end of file +end + +desc 'Execute RuboCop static code analysis' +RuboCop::RakeTask.new(:rubocop) do |t| + t.patterns = %w(**/*.rb) + t.options = %w(-D) + t.fail_on_error = false +end