Class: Moon::Test::T

Inherits:
Object show all
Defined in:
lib/moon/packages/test/t.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeT


16
17
18
19
20
# File 'lib/moon/packages/test/t.rb', line 16

def initialize
  @logger = nil
  @failed = false
  @skipped = false
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger


14
15
16
# File 'lib/moon/packages/test/t.rb', line 14

def logger
  @logger
end

Instance Method Details

#error(*args) ⇒ Object


53
54
55
56
# File 'lib/moon/packages/test/t.rb', line 53

def error(*args)
  log(*args)
  fail
end

#errorf(string, *args) ⇒ Object


58
59
60
61
# File 'lib/moon/packages/test/t.rb', line 58

def errorf(string, *args)
  logf(string, *args)
  fail
end

#failObject


22
23
24
# File 'lib/moon/packages/test/t.rb', line 22

def fail
  @failed = true
end

#fail_nowObject

Raises:


26
27
28
29
# File 'lib/moon/packages/test/t.rb', line 26

def fail_now
  fail
  raise TestFail
end

#failed?Boolean


31
32
33
# File 'lib/moon/packages/test/t.rb', line 31

def failed?
  @failed
end

#fatal(*args) ⇒ Object


43
44
45
46
# File 'lib/moon/packages/test/t.rb', line 43

def fatal(*args)
  log(*args)
  fail_now
end

#fatalf(string, *args) ⇒ Object


48
49
50
51
# File 'lib/moon/packages/test/t.rb', line 48

def fatalf(string, *args)
  logf(string, *args)
  fail_now
end

#log(*args) ⇒ Object


39
40
41
# File 'lib/moon/packages/test/t.rb', line 39

def log(*args)
  logf('%s', *args)
end

#logf(string, *args) ⇒ Object


35
36
37
# File 'lib/moon/packages/test/t.rb', line 35

def logf(string, *args)
  @logger.puts sprintf(string, *args) if @logger
end

#skip(*args) ⇒ Object


68
69
70
71
# File 'lib/moon/packages/test/t.rb', line 68

def skip(*args)
  log(*args)
  skip_now
end

#skip_nowObject

Raises:


63
64
65
66
# File 'lib/moon/packages/test/t.rb', line 63

def skip_now
  @skipped = true
  raise TestSkip
end

#skipf(string, *args) ⇒ Object


73
74
75
76
# File 'lib/moon/packages/test/t.rb', line 73

def skipf(string, *args)
  logf(string, *args)
  skip_now
end

#skipped?Boolean


78
79
80
# File 'lib/moon/packages/test/t.rb', line 78

def skipped?
  @skipped
end