Sha256: 56cf53ac6ec617c328e9796a48c01063dc7b38f4430d5239badc56e254b37f75

Contents?: true

Size: 1.88 KB

Versions: 11

Compression:

Stored size: 1.88 KB

Contents

module Calabash
  module IOS
    # @!visibility private
    module Routes
      # @!visibility private
      module ConditionRouteMixin

        # @!visibility private
        def condition_route(condition, timeout, query)
          request = make_condition_request(condition, timeout, query)
          response = route_post_request(request)
          handle_condition_response(response)
        end

        private

        #                         server
        #    key                  default   description
        # :condition    required
        # :timeout      optional     *     how long to wait
        # :duration     optional    0.2    time after which condition can be considered met
        # :frequency    optional    0.2    how often to check condition
        # :query           !        n/a    apply condition to matched views
        #
        # * => 6.0 for none animating and 30.0 for network indicator
        # ! => query is required for none animating!
        #
        # The :duration and :frequency are not part of the public API.
        def make_condition_parameters(condition, timeout, query)
          {
                :condition => condition,
                :timeout => timeout,
                :query => query
          }
        end

        def make_condition_request(condition, timeout, query)
          parameters = make_condition_parameters(condition, timeout, query)
          begin
            Calabash::HTTP::Request.request('condition', parameters)
          rescue => e
            raise Calabash::IOS::RouteError, e
          end
        end

        def handle_condition_response(response)
          hash = parse_response_body(response)

          outcome = hash['outcome']

          case outcome
            when 'FAILURE'
              false
            when 'SUCCESS'
              true
            else
              nil
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
calabash-2.0.0.pre11 lib/calabash/ios/device/routes/condition_route_mixin.rb
calabash-2.0.0.pre10 lib/calabash/ios/device/routes/condition_route_mixin.rb
calabash-2.0.0.pre9 lib/calabash/ios/device/routes/condition_route_mixin.rb
calabash-2.0.0.prelegacy4 lib/calabash/ios/device/routes/condition_route_mixin.rb
calabash-2.0.0.prelegacy3 lib/calabash/ios/device/routes/condition_route_mixin.rb
calabash-2.0.0.prelegacy2 lib/calabash/ios/device/routes/condition_route_mixin.rb
calabash-2.0.0.prelegacy lib/calabash/ios/device/routes/condition_route_mixin.rb
calabash-2.0.0.pre6 lib/calabash/ios/device/routes/condition_route_mixin.rb
calabash-2.0.0.pre5 lib/calabash/ios/device/routes/condition_route_mixin.rb
calabash-2.0.0.pre4 lib/calabash/ios/device/routes/condition_route_mixin.rb
calabash-2.0.0.pre3 lib/calabash/ios/device/routes/condition_route_mixin.rb