Module: Kintama::Test
- Includes:
- Assertions
- Defined in:
- lib/kintama/test.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Assertions
#assert, #assert_equal, #assert_kind_of, #assert_match, #assert_nil, #assert_no_match, #assert_not_equal, #assert_not_nil, #assert_not_output, #assert_nothing_raised, #assert_output, #assert_raises, #assert_same, #assert_same_elements, #flunk
Class Method Details
.included(base) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/kintama/test.rb', line 7
def self.included(base)
class << base
attr_accessor :block
def pending?
!instance_variable_defined?(:@block) || @block.nil?
end
def run
new.run
end
end
base.send :attr_reader, :failure
end
|
Instance Method Details
#failure_backtrace ⇒ Object
63
64
65
66
|
# File 'lib/kintama/test.rb', line 63
def failure_backtrace
base_dir = File.expand_path("../..", __FILE__)
@failure.backtrace.select { |line| File.expand_path(line).index(base_dir).nil? }.map { |l| " "*4 + File.expand_path(l) }.join("\n")
end
|
#failure_message ⇒ Object
59
60
61
|
# File 'lib/kintama/test.rb', line 59
def failure_message
"#{@failure.message}\n#{failure_backtrace}"
end
|
#full_name ⇒ Object
55
56
57
|
# File 'lib/kintama/test.rb', line 55
def full_name
self.class.full_name
end
|
#name ⇒ Object
51
52
53
|
# File 'lib/kintama/test.rb', line 51
def name
self.class.name
end
|
#passed? ⇒ Boolean
47
48
49
|
# File 'lib/kintama/test.rb', line 47
def passed?
@failure.nil?
end
|
#pending? ⇒ Boolean
43
44
45
|
# File 'lib/kintama/test.rb', line 43
def pending?
self.class.pending?
end
|
#run(reporter = nil) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/kintama/test.rb', line 22
def run(reporter=nil)
@failure = nil
reporter.test_started(self) if reporter
unless pending?
begin
setup
instance_eval(&self.class.block)
rescue Exception => e
@failure = e
ensure
begin
teardown
rescue Exception => e
@failure ||= e
end
end
end
reporter.test_finished(self) if reporter
passed?
end
|