Class: Bunny::TestKit
- Inherits:
-
Object
- Object
- Bunny::TestKit
- Defined in:
- lib/bunny/test_kit.rb
Overview
Unit, integration and stress testing toolkit
Class Method Summary collapse
-
.message_in_kb(a, b, i) ⇒ String
Message payload of length in the given range, with non-ASCII characters.
- .poll_until(timeout = 60, &probe) ⇒ Object
- .poll_while(timeout = 60, &probe) ⇒ Object
-
.random_in_range(a, b) ⇒ Integer
private
Random integer in the range of [a, b].
Class Method Details
.message_in_kb(a, b, i) ⇒ String
Returns Message payload of length in the given range, with non-ASCII characters.
32 33 34 35 36 37 |
# File 'lib/bunny/test_kit.rb', line 32 def (a, b, i) s = "Ю#{i}" n = random_in_range(a, b) / s.bytesize s * n * 1024 end |
.poll_until(timeout = 60, &probe) ⇒ Object
15 16 17 18 19 |
# File 'lib/bunny/test_kit.rb', line 15 def poll_until(timeout = 60, &probe) Timeout.timeout(timeout) { sleep 0.1 until probe.call } end |
.poll_while(timeout = 60, &probe) ⇒ Object
10 11 12 13 14 |
# File 'lib/bunny/test_kit.rb', line 10 def poll_while(timeout = 60, &probe) Timeout.timeout(timeout) { sleep 0.1 while probe.call } 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].
23 24 25 |
# File 'lib/bunny/test_kit.rb', line 23 def random_in_range(a, b) Range.new(a, b).to_a.sample end |