Sha256: 4bc99de4734e4bdd7a9826e4df08d437ef308fc2f650ce9d8fb7e2b26c5a1e3e

Contents?: true

Size: 725 Bytes

Versions: 3

Compression:

Stored size: 725 Bytes

Contents

# -*- coding: utf-8 -*-
module Bunny
  # Unit, integration and stress testing toolkit
  class TestKit
    class << self

      # @return [Integer] Random integer in the range of [a, b]
      # @api private
      def random_in_range(a, b)
        Range.new(a, b).to_a.sample
      end

      # @param  [Integer] Lower bound of message size, in KB
      # @param  [Integer] Upper bound of message size, in KB
      # @param  [Integer] Random number to use in message generation
      # @return [String] Message payload of length in the given range, with non-ASCII characters
      def message_in_kb(a, b, i)
        s = "Ю#{i}"
        n = random_in_range(a, b) / s.bytesize

        s * n * 1024
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bunny-0.9.0.pre13 lib/bunny/test_kit.rb
bunny-0.9.0.pre12 lib/bunny/test_kit.rb
bunny-0.9.0.pre11 lib/bunny/test_kit.rb