Module: Test::Unit::Context::Helpers

Defined in:
lib/test/unit/context/helpers.rb

Class Method Summary collapse

Class Method Details

.generate_uuidObject



18
19
20
21
22
# File 'lib/test/unit/context/helpers.rb', line 18

def generate_uuid
  uuid = [ (Time.now.to_f * 1000).to_i % 10 ]
  15.times { uuid << rand(16).to_s(16) }
  uuid.join
end

.to_const_name(str, prefix = nil, suffix = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/test/unit/context/helpers.rb', line 8

def to_const_name(str, prefix = nil, suffix = nil)
  name = str.dup
  name.lstrip! if prefix
  name.rstrip! if suffix
  name.gsub!(/[\s:',\.~;!#=\(\)&]+/, '_')
  name.gsub!(/\/(.?)/) { $1.upcase }
  name.gsub!(/(?:^|_)(.)/) { $1.upcase }
  "#{prefix}#{name}#{suffix}"
end