class Bunny::TestKit

Unit, integration and stress testing toolkit

Public Class Methods

message_in_kb(a, b, i) click to toggle source

@param [Integer] a Lower bound of message size, in KB @param [Integer] b Upper bound of message size, in KB @param [Integer] i Random number to use in message generation @return [String] Message payload of length in the given range, with non-ASCII characters @api public

# File lib/bunny/test_kit.rb, line 31
def message_in_kb(a, b, i)
  s = "Ю#{i}"
  n = random_in_range(a, b) / s.bytesize

  s * n * 1024
end
poll_until(timeout = 60, &probe) click to toggle source
# File lib/bunny/test_kit.rb, line 14
def poll_until(timeout = 60, &probe)
  Timeout.timeout(timeout) {
    sleep 0.1 until probe.call
  }
end
poll_while(timeout = 60, &probe) click to toggle source
# File lib/bunny/test_kit.rb, line 9
def poll_while(timeout = 60, &probe)
  Timeout.timeout(timeout) {
    sleep 0.1 while probe.call
  }
end
random_in_range(a, b) click to toggle source

@return [Integer] Random integer in the range of [a, b] @api private

# File lib/bunny/test_kit.rb, line 22
def random_in_range(a, b)
  Range.new(a, b).to_a.sample
end