lib/calabash-cucumber/device_agent.rb in calabash-cucumber-0.20.0 vs lib/calabash-cucumber/device_agent.rb in calabash-cucumber-0.20.3

- old
+ new

@@ -22,11 +22,11 @@ def initialize(client, world) @client = client @world = world end - # @!visibility private + # Query the UI for elements. # # @example # query({id: "login", :type "Button"}) # # query({marked: "login"}) @@ -124,11 +124,11 @@ # @param uiquery See #query # @return [Hash] The center of first view matched by query. # # @raise [RuntimeError] if no view matches the uiquery after waiting. def query_for_coordinate(uiquery) - fail_with_screenshot { client.query_for_coordinate(uiquery) } + with_screenshot_on_failure { client.query_for_coordinate(uiquery) } end # Perform a touch on the center of the first view matched the uiquery. # # This method waits for the query to match at least one element. @@ -138,11 +138,11 @@ # @param [Hash] uiquery See #query for examples. # @return [Array<Hash>] The view that was touched. # # @raise [RuntimeError] if no view matches the uiquery after waiting. def touch(uiquery) - fail_with_screenshot { client.touch(uiquery) } + with_screenshot_on_failure { client.touch(uiquery) } end # Perform a touch at a coordinate. # # This method does not wait; the touch is performed immediately. @@ -171,11 +171,11 @@ # @param uiquery See #query # @return [Array<Hash>] The view that was touched. # # @raise [RuntimeError] if no view matches the uiquery after waiting. def double_tap(uiquery) - fail_with_screenshot { client.double_tap(uiquery) } + with_screenshot_on_failure { client.double_tap(uiquery) } end # Perform a two finger tap on the center of the first view matched the uiquery. # # @see #query @@ -185,11 +185,11 @@ # @param uiquery See #query # @return [Array<Hash>] The view that was touched. # # @raise [RuntimeError] if no view matches the uiquery after waiting. def two_finger_tap(uiquery) - fail_with_screenshot { client.two_finger_tap(uiquery) } + with_screenshot_on_failure { client.two_finger_tap(uiquery) } end # Perform a long press on the center of the first view matched the uiquery. # # @see #query @@ -200,11 +200,11 @@ # @param [Numeric] duration How long to press. # @return [Array<Hash>] The view that was touched. # # @raise [RuntimeError] if no view matches the uiquery after waiting. def long_press(uiquery, duration) - fail_with_screenshot { client.long_press(uiquery, {:duration => duration}) } + with_screenshot_on_failure { client.long_press(uiquery, {:duration => duration}) } end # Returns true if there is a keyboard visible. # # Scheduled for removal in 0.21.0. Use Core#keyboard_visible?. If you @@ -226,11 +226,11 @@ # @param [String] text the text to enter # # @raise [RuntimeError] if there is no visible keyboard. # @deprecated 0.21.0 Use Core#enter_text def enter_text(text) - fail_with_screenshot { client.enter_text(text) } + with_screenshot_on_failure { client.enter_text(text) } end # Enter text into the first view matched by uiquery. # # This method waits for the query to match at least one element and for @@ -242,11 +242,11 @@ # @raise [RuntimeError] if no view matches the uiquery after waiting. # @raise [RuntimeError] if the touch does not cause a keyboard to appear. # # @deprecated 0.21.0 Use Core#enter_text def enter_text_in(uiquery, text) - fail_with_screenshot do + with_screenshot_on_failure do client.touch(uiquery) client.wait_for_keyboard client.enter_text(text) end end @@ -310,32 +310,18 @@ def springboard_alert client.springboard_alert end =begin -PROTECTED -=end - protected - - # @!visibility private - def method_missing(name, *args, &block) - if world.respond_to?(name) - world.send(name, *args, &block) - else - super - end - end - -=begin PRIVATE =end private # @!visibility private attr_reader :client, :world # @!visibility private - def fail_with_screenshot(&block) + def with_screenshot_on_failure(&block) begin block.call rescue => e world.send(:fail, e.message) end