author | Mahlon E. Smith <mahlon@martini.nu> |
Sat, 18 Dec 2010 00:56:09 -0800 | |
branch | vim-stuff |
changeset 19 | 763cef799c74 |
child 21 | cd1f3381c1ed |
permissions | -rw-r--r-- |
19
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
1 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
2 |
require 'rspec/core/formatters/base_text_formatter' |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
3 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
4 |
### SpeckyFormatter: A basic RSpec 2.x text formatter, to be used |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
5 |
### with the 'Specky' vim plugin (or from the command line, if you |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
6 |
### dig it over the default 'documentation' format!) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
7 |
### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
8 |
### rspec -r /path/to/this/specky_formatter.rb -f SpeckyFormatter specs |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
9 |
### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
10 |
class SpeckyFormatter < RSpec::Core::Formatters::BaseTextFormatter |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
11 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
12 |
def initialize( *args ) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
13 |
super |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
14 |
@indent_level = 0 |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
15 |
@failure_index = 0 |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
16 |
@failures = [] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
17 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
18 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
19 |
######################################################################## |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
20 |
### R S P E C H O O K S |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
21 |
######################################################################## |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
22 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
23 |
### Example group hook -- increase indentation, emit description |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
24 |
### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
25 |
def example_group_started( example_group ) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
26 |
output.puts |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
27 |
self.out '+', '-' * (example_group.description.length + 2), '+' |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
28 |
self.out '| ', example_group.description, ' |' |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
29 |
self.out '+', '-' * (example_group.description.length + 2), '+' |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
30 |
@indent_level += 1 |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
31 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
32 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
33 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
34 |
### Example group hook -- decrease indentation |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
35 |
### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
36 |
def example_group_finished( example_group ) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
37 |
@indent_level -= 1 |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
38 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
39 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
40 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
41 |
### Called on example success |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
42 |
### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
43 |
def example_passed( example ) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
44 |
msg = self.format_example( example ) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
45 |
msg << ')' |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
46 |
self.out msg |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
47 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
48 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
49 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
50 |
### Called on a pending example |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
51 |
### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
52 |
def example_pending( example ) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
53 |
msg = self.format_example( example ) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
54 |
pending_msg = example.metadata[ :execution_result ][ :pending_message ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
55 |
msg << ", PENDING%s)" % [ ": #{pending_msg}" || '' ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
56 |
self.out msg |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
57 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
58 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
59 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
60 |
### Called on example failure |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
61 |
### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
62 |
def example_failed( example ) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
63 |
@failure_index += 1 |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
64 |
msg = self.format_example( example ) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
65 |
msg << ", FAILED - #%d)" % [ @failure_index ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
66 |
self.out msg |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
67 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
68 |
@failures << example |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
69 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
70 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
71 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
72 |
### Called after all examples are run. Emit details for each failed example, |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
73 |
### for Vim to fold. |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
74 |
### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
75 |
def dump_failures |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
76 |
self.out "\n\n\n" unless @failures.empty? |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
77 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
78 |
@failures.each_with_index do |example, index| |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
79 |
desc = example.metadata[ :full_description ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
80 |
exception = example.execution_result[ :exception ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
81 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
82 |
self.out "FAILURE - #%d)" % [ index + 1 ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
83 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
84 |
if RSpec::Core::PendingExampleFixedError === exception |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
85 |
self.out "%s FIXED" % [ desc ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
86 |
self.out "Expected pending '%s' to fail. No error was raised." % [ |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
87 |
example.metadata[ :execution_result ][ :pending_message ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
88 |
] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
89 |
else |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
90 |
self.out desc |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
91 |
self.out "Failure/Error: %s" % [ read_failed_line( exception, example).strip ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
92 |
exception.message.split("\n").each {|l| self.out l} |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
93 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
94 |
# logic taken from the base class |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
95 |
example.example_group.ancestors.push(example.example_group).each do |group| |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
96 |
if group.metadata[:shared_group_name] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
97 |
self.out "Shared Example Group: \"#{group.metadata[:shared_group_name]}\" called from " + |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
98 |
"#{backtrace_line(group.metadata[:example_group][:location])}" |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
99 |
break |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
100 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
101 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
102 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
103 |
self.out "\n" |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
104 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
105 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
106 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
107 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
108 |
### Emit summary data for all examples. |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
109 |
### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
110 |
def dump_summary( duration, example_count, failure_count, pending_count ) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
111 |
succeeded = example_count - failure_count - pending_count |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
112 |
self.out '+', '-' * 49, '+' |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
113 |
self.out '|', ' ' * 18, '-- Summary --', ' ' * 18, '|' |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
114 |
self.out '+----------+-----------+--------+---------+-------+' |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
115 |
self.out '| Duration | Succeeded | Failed | Pending | Total |' |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
116 |
self.out '+----------+-----------+--------+---------+-------+' |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
117 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
118 |
self.out "| %7ss | %9s | %6s | %7s | %5s |" % [ |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
119 |
"%0.3f" % duration, succeeded, failure_count, |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
120 |
pending_count, example_count |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
121 |
] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
122 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
123 |
self.out '+----------+-----------+--------+---------+-------+' |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
124 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
125 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
126 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
127 |
######### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
128 |
protected |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
129 |
######### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
130 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
131 |
### Send a string to the output IO object, after indentation. |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
132 |
### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
133 |
def out( *msg ) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
134 |
msg = msg.join |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
135 |
output.puts "%s%s" % [ ' ' * @indent_level, msg ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
136 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
137 |
|
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
138 |
### Format the basic example information, along with the run duration. |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
139 |
### |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
140 |
def format_example( example ) |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
141 |
metadata = example.metadata |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
142 |
duration = metadata[ :execution_result ][ :run_time ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
143 |
description = metadata[ :description ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
144 |
return "| %s (%0.3fs" % [ description, duration ] |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
145 |
end |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
146 |
end # SpeckyFormatter |
763cef799c74
Specky: support rspec 2.x by default.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
147 |