Module: JayUnit

Defined in:
lib/jay_unit.rb,
lib/jay_unit/version.rb

Defined Under Namespace

Classes: Mock, Test

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

._run_test(name) ⇒ Object



21
22
23
24
25
26
# File 'lib/jay_unit.rb', line 21

def self._run_test(name)
  cls = Kernel.const_get(name)
  if cls then
    inst = cls.new
  end
end

.mockObject



18
19
20
# File 'lib/jay_unit.rb', line 18

def self.mock
  return JayUnit::Mock.new
end

.note(str) ⇒ Object



15
16
17
# File 'lib/jay_unit.rb', line 15

def self.note(str)
  puts "......#{str}"
end

.phail(str) ⇒ Object



9
10
11
12
13
14
# File 'lib/jay_unit.rb', line 9

def self.phail(str)
  $fls += 1
  s = %Q[PHAILURE: #{str}]
  raise s
  exit
end

.run(test_name = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/jay_unit.rb', line 27

def self.run(test_name=nil)
  Dir.glob("#{::Rails.root.to_s}/test/unit/*_unit.rb").each do |f|
    require f
    name = f.split('/').last
    name.gsub!(/^(\w)/) {$1.upcase}
    name.gsub!(/_(\w)/) {$1.upcase}
    name.gsub!(/\.rb/,'')
    if test_name.nil? then
      puts "JayUnit: Running #{name}."
      JayUnit._run_test name
      puts "JayUnit: #{name} complete."
    elsif test_name == name then
      puts "JayUnit: Running #{name}."
      JayUnit._run_test name
      puts "JayUnit: #{name} complete."
    end
  end
end

.succeed(str) ⇒ Object



4
5
6
7
8
# File 'lib/jay_unit.rb', line 4

def self.succeed(str)
  $ses += 1
  s = %Q[SUCCESS: #{str}]
  puts s
end