Sha256: 8232466ede204cbd5e9fa9b22c39112806d529c6ccb97138c86c504e56a9abec

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module XamarinTestCloud
  module Cukes
    module Retriable

      class Error < StandardError
      end

      def method_that_raises(n)
        unless n >= 3
          raise XamarinTestCloud::Cukes::Retriable::Error, "n: '#{n}' argument is < 3"
        end
        true
      end
    end
  end
end

World(XamarinTestCloud::Cukes::Retriable)

Then(/^I call retriable$/) do

  tries = 5
  interval = 0.05

  on_retry = Proc.new do |_, try, elapsed_time, next_interval|
    if elapsed_time && next_interval
      puts "Updating device state attempt #{try} failed in '#{elapsed_time}'; will retry in '#{next_interval}'"
    else
      puts "Updating device state attempt #{try} failed; will retry in #{interval}"
    end
  end

  on_opts =
        {
              :on_retry => on_retry,
              :on => [XamarinTestCloud::Cukes::Retriable::Error]
        }

  retry_opts = XamarinTestCloud::RetriableOptions.tries_and_interval(tries, interval)

  opts = on_opts.merge(retry_opts)

  counter = 0
  Retriable.retriable(opts) do
    begin
      method_that_raises(counter)
    ensure
      counter = counter + 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xamarin-test-cloud-1.1.2 test/retriable/features/step_definitions/retriable_steps.rb