module NetHttp2

  module ApiHelpers

    def wait_for(seconds=2, &block)
      (0..seconds).each do
        break if block.call
        sleep 1
      end
    end
  end
end

module NetHttp2

  module ApiHelpers
    WAIT_INTERVAL = 0.2

    def wait_for(seconds=2, &block)
      count = 1 / WAIT_INTERVAL

      (0..(count * seconds)).each do
        break if block.call
        sleep WAIT_INTERVAL
      end
    end
  end
end

Refactor wait for helper to speed up tests.
Refactor wait for helper to speed up tests.
