Class: Bunny::TestKit

Inherits:
Object
  • Object
show all
Defined in:
lib/bunny/test_kit.rb

Overview

Unit, integration and stress testing toolkit

Class Method Summary collapse

Class Method Details

.message_in_kb(a, b, i) ⇒ String

Returns Message payload of length in the given range, with non-ASCII characters

Parameters:

  • a (Integer)

    Lower bound of message size, in KB

  • b (Integer)

    Upper bound of message size, in KB

  • i (Integer)

    Random number to use in message generation

Returns:

  • (String)

    Message payload of length in the given range, with non-ASCII characters



18
19
20
21
22
23
# File 'lib/bunny/test_kit.rb', line 18

def message_in_kb(a, b, i)
  s = "Ю#{i}"
  n = random_in_range(a, b) / s.bytesize

  s * n * 1024
end

.random_in_range(a, b) ⇒ Integer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Random integer in the range of [a, b]

Returns:

  • (Integer)

    Random integer in the range of [a, b]



9
10
11
# File 'lib/bunny/test_kit.rb', line 9

def random_in_range(a, b)
  Range.new(a, b).to_a.sample
end