Class: Uspec::Result
Constant Summary
collapse
- PREFIX =
"#{Uspec::Terminal.newline}#{Uspec::Terminal.yellow}>\t#{Uspec::Terminal.normal}"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Terminal
color, colors, esc, hspace, method_missing, newline, normal, vspace
Constructor Details
#initialize(spec, raw, ex) ⇒ Result
Returns a new instance of Result.
10
11
12
13
14
15
16
17
|
# File 'lib/uspec/result.rb', line 10
def initialize spec, raw, ex
@spec = spec
@raw = raw
@ex = ex
@handler = ::TOISB.wrap raw
@full_backtrace = false
@caller = caller
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Uspec::Terminal
Instance Attribute Details
#ex ⇒ Object
Returns the value of attribute ex.
18
19
20
|
# File 'lib/uspec/result.rb', line 18
def ex
@ex
end
|
#full_backtrace ⇒ Object
Returns the value of attribute full_backtrace.
18
19
20
|
# File 'lib/uspec/result.rb', line 18
def full_backtrace
@full_backtrace
end
|
#handler ⇒ Object
Returns the value of attribute handler.
18
19
20
|
# File 'lib/uspec/result.rb', line 18
def handler
@handler
end
|
#raw ⇒ Object
Returns the value of attribute raw.
18
19
20
|
# File 'lib/uspec/result.rb', line 18
def raw
@raw
end
|
#spec ⇒ Object
Returns the value of attribute spec.
18
19
20
|
# File 'lib/uspec/result.rb', line 18
def spec
@spec
end
|
Instance Method Details
#desc ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/uspec/result.rb', line 42
def desc
if String === spec then
spec
elsif Uspec::Spec === spec then
spec.instance_variable_get :@__uspec_description
else
spec.inspect
end
end
|
#failure? ⇒ Boolean
87
88
89
|
# File 'lib/uspec/result.rb', line 87
def failure?
raw != true && !@pending
end
|
#inspect ⇒ Object
99
100
101
|
# File 'lib/uspec/result.rb', line 99
def inspect
"#{self.class} for `#{desc}` -> #{pretty}"
end
|
#inspector ⇒ Object
Attempts to inspect an object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/uspec/result.rb', line 63
def inspector
if String === raw && raw.include?(?\n) then
[
raw.split(newline).unshift(newline).join(PREFIX), normal, newline,
].join
elsif Exception === raw then
Uspec::Errors.msg_spec_value raw
else
handler.inspector!
end
rescue Exception => error
return handler.simple_inspector if error.message.include? handler.get_id
[
red('Unable to Inspect Object'), newline,
Uspec::Errors.msg_source_error(error, desc),
].join
end
|
#nonboolean ⇒ Object
52
53
54
55
56
57
58
59
60
|
# File 'lib/uspec/result.rb', line 52
def nonboolean
[
red('Failed'), vspace,
hspace, 'Spec did not return a boolean value ', newline,
hspace, 'in spec at ', source.first, vspace,
hspace, red(subklassinfo), inspector, (Class === raw ? ' Class' : ''), newline
].join
end
|
#pending! ⇒ Object
95
96
97
|
# File 'lib/uspec/result.rb', line 95
def pending!
@pending = true
end
|
#pending? ⇒ Boolean
91
92
93
|
# File 'lib/uspec/result.rb', line 91
def pending?
!!@pending
end
|
#pretty ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/uspec/result.rb', line 20
def pretty
if raw == true then
green raw
elsif raw == false then
red raw
elsif pending? then
yellow 'pending'
elsif ex == true then
Uspec::Errors.msg_spec_error raw, desc
else
nonboolean
end
end
|
#source ⇒ Object
34
35
36
|
# File 'lib/uspec/result.rb', line 34
def source
@source ||= Uspec::Errors.bt_clean @caller
end
|
#subklassinfo ⇒ Object
38
39
40
|
# File 'lib/uspec/result.rb', line 38
def subklassinfo
"#{handler.subklassinfo}: "
end
|
#success? ⇒ Boolean
83
84
85
|
# File 'lib/uspec/result.rb', line 83
def success?
raw == true
end
|