android_tests/lib/android/specs/common/helper.rb in appium_lib-6.0.0 vs android_tests/lib/android/specs/common/helper.rb in appium_lib-7.0.0

- old
+ new

@@ -1,42 +1,40 @@ describe 'common/helper' do wait_opts = { timeout: 0.2, interval: 0.2 } # max_wait, interval -=begin -There's no `must_not_raise` as the opposite of must_raise + # There's no `must_not_raise` as the opposite of must_raise -By default code is expected to not raise exceptions. -must_not_raise is a no-op. -=end + # By default code is expected to not raise exceptions. + # must_not_raise is a no-op. # wait is a success unless an error is raised # max_wait=0 is infinity to use 0.1 t 'wait' do # successful wait should not raise error wait(wait_opts) { true } wait(wait_opts) { false } wait(wait_opts) { nil } # failed wait should error - proc { wait(wait_opts) { raise } }.must_raise Selenium::WebDriver::Error::TimeOutError + proc { wait(wait_opts) { fail } }.must_raise Selenium::WebDriver::Error::TimeOutError # regular rescue will not handle exceptions outside of StandardError hierarchy # must rescue Exception explicitly to rescue everything - proc { wait(wait_opts) { raise NoMemoryError } }.must_raise Selenium::WebDriver::Error::TimeOutError - proc { wait(timeout: 0.2, interval: 0.0) { raise NoMemoryError } }.must_raise Selenium::WebDriver::Error::TimeOutError + proc { wait(wait_opts) { fail NoMemoryError } }.must_raise Selenium::WebDriver::Error::TimeOutError + proc { wait(timeout: 0.2, interval: 0.0) { fail NoMemoryError } }.must_raise Selenium::WebDriver::Error::TimeOutError # invalid keys are rejected proc { wait(invalidkey: 2) { true } }.must_raise RuntimeError end t 'ignore' do # ignore should rescue all exceptions ignore { true } ignore { false } ignore { nil } - ignore { raise } - ignore { raise NoMemoryError } + ignore { fail } + ignore { fail NoMemoryError } end # wait_true is a success unless the value is not true t 'wait_true' do # successful wait should not error @@ -45,16 +43,17 @@ # failed wait should error proc { wait_true(wait_opts) { false } }.must_raise Selenium::WebDriver::Error::TimeOutError proc { wait_true(wait_opts) { nil } }.must_raise Selenium::WebDriver::Error::TimeOutError # raise should error - proc { wait_true(wait_opts) { raise } }.must_raise Selenium::WebDriver::Error::TimeOutError + proc { wait_true(wait_opts) { fail } }.must_raise Selenium::WebDriver::Error::TimeOutError # regular rescue will not handle exceptions outside of StandardError hierarchy # must rescue Exception explicitly to rescue everything - proc { wait_true(wait_opts) { raise NoMemoryError } }.must_raise Selenium::WebDriver::Error::TimeOutError - proc { wait_true(timeout: 0.2, interval: 0.0) { raise NoMemoryError } }.must_raise Selenium::WebDriver::Error::TimeOutError + proc { wait_true(wait_opts) { fail NoMemoryError } }.must_raise Selenium::WebDriver::Error::TimeOutError + proc { wait_true(timeout: 0.2, interval: 0.0) { fail NoMemoryError } } + .must_raise Selenium::WebDriver::Error::TimeOutError # invalid keys are rejected proc { wait_true(invalidkey: 2) { true } }.must_raise RuntimeError end @@ -70,11 +69,11 @@ # start page wait { find 'NFC' } end t 'session_id' do - wait { session_id.must_match /\h{8}-\h{4}-\h{4}-\h{4}-\h{12}/ } + wait { session_id.must_match(/\h{8}-\h{4}-\h{4}-\h{4}-\h{12}/) } end t 'xpath' do wait { xpath('//android.widget.TextView').name.must_equal 'API Demos' } end @@ -108,6 +107,6 @@ t 'get_source' do wait do get_source.class.must_equal String end end -end \ No newline at end of file +end