Class: Rgot::T
Instance Attribute Summary
Attributes inherited from Common
#output
Instance Method Summary
collapse
Methods inherited from Common
#error, #errorf, #fail!, #fail_now, #failed?, #fatal, #fatalf, #finish!, #finished?, #log, #logf, #skip, #skip!, #skip_now, #skipf, #skipped?
Constructor Details
#initialize(test_module, name) ⇒ T
Returns a new instance of T.
3
4
5
6
7
8
|
# File 'lib/rgot/t.rb', line 3
def initialize(test_module, name)
super()
@module = test_module
@name = name
@module.extend @module
end
|
Instance Method Details
#call ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'lib/rgot/t.rb', line 33
def call
test_method = @module.instance_method(@name).bind(@module)
if test_method.arity == 0
path, line = test_method.source_location
warn "#{path}:#{line} `#{test_method.name}' is not running. It's a testing method name, But not have argument"
else
test_method.call(self)
end
end
|
#report ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/rgot/t.rb', line 19
def report
duration = Rgot.now - @start
template = "--- %s: %s (%.2fs)\n%s"
if failed?
printf template, "FAIL", @name, duration, @output
elsif Rgot.verbose?
if skipped?
printf template, "SKIP", @name, duration, @output
else
printf template, "PASS", @name, duration, @output
end
end
end
|
#run ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/rgot/t.rb', line 10
def run
catch(:skip) { call }
finish!
rescue => e
fail!
report
raise e
end
|