ios_tests/lib/ios/specs/driver.rb in appium_lib-9.0.0 vs ios_tests/lib/ios/specs/driver.rb in appium_lib-9.1.0

- old
+ new

@@ -31,17 +31,20 @@ end describe 'Appium::Driver attributes' do t 'verify all attributes' do 2.times { set_wait 30 } # must set twice to validate last_waits - actual = driver_attributes - actual[:caps][:app] = File.basename actual[:caps][:app] - expected = { caps: { platformName: 'ios', - platformVersion: '10.1', - automationName: 'XCUITest', - deviceName: 'iPhone Simulator', - app: 'UICatalog.app' }, + actual = driver_attributes + caps_app_for_teardown = actual[:caps][:app] + actual[:caps][:app] = File.basename actual[:caps][:app] + + expected_caps = ::Appium::Driver::Capabilities.init_caps_for_appium(platformName: 'ios', + platformVersion: '10.1', + automationName: 'XCUITest', + deviceName: 'iPhone Simulator', + app: 'UICatalog.app') + expected = { caps: expected_caps, custom_url: false, export_session: false, default_wait: 30, last_waits: [30, 30], sauce_username: nil, @@ -52,23 +55,39 @@ listener: nil } if actual != expected diff = HashDiff.diff expected, actual diff = "diff (expected, actual):\n#{diff}" + + actual[:caps][:app] = caps_app_for_teardown # example: # change :ios in expected to match 'ios' in actual # [["~", "caps.platformName", :ios, "ios"]] message = "\n\nactual:\n\n: #{actual.ai}expected:\n\n#{expected.ai}\n\n#{diff}" - fail message + raise message end + + actual_selenium_caps = actual[:caps][:automationName] + actual_selenium_caps.must_equal 'XCUITest' + actual[:caps][:app] = caps_app_for_teardown end t 'verify attributes are immutable' do + driver_attributes[:custom_url] = true + expected = false + driver_attributes[:custom_url].must_equal expected + end + + t 'verify attribute of :caps are not immutable becuse it depends on Selenium' do + # immutability depends on Selenium + for_clean_up = driver_attributes[:caps][:app].dup driver_attributes[:caps][:app] = 'fake' - actual = File.basename driver_attributes[:caps][:app] - expected = 'UICatalog.app' - actual.must_equal expected + expected = 'fake' + driver_attributes[:caps][:app].must_equal expected + + # clean up + driver_attributes[:caps][:app] = for_clean_up end t 'no_wait' do no_wait default_wait.must_equal 0 @@ -186,16 +205,16 @@ end # returns true unless an error is raised t 'exists' do exists(0, 0) { true }.must_equal true - exists(0, 0) { fail 'error' }.must_equal false + exists(0, 0) { raise 'error' }.must_equal false end # simple integration sanity test to check for unexpected exceptions t 'set_location' do - fail NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest? + raise NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest? set_location latitude: 55, longitude: -72, altitude: 33 end # any elements t 'find_elements' do @@ -207,15 +226,15 @@ find_element(:class, UI::Inventory.static_text).class.must_equal Selenium::WebDriver::Element end # settings t 'get settings' do - fail NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest? + raise NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest? get_settings.wont_be_nil end t 'update settings' do - fail NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest? + raise NotImplementedError, "XCUITest(Appium1.6.2) doesn't support yet" if UI::Inventory.xcuitest? update_settings cyberdelia: 'open' get_settings['cyberdelia'].must_equal 'open' end