-
Notifications
You must be signed in to change notification settings - Fork 124
/
rspec3.rb
70 lines (54 loc) · 1.4 KB
/
rspec3.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter
RSpec::Core::Formatters.register self,
:start,
:stop,
:dump_summary
def start(notification)
@start_notification = notification
@started = Time.now
super
end
def stop(notification)
@examples_notification = notification
end
def dump_summary(notification)
@summary_notification = notification
xml_dump
end
private
attr_reader :started
def example_count
@summary_notification.examples.count
end
def failure_count
@summary_notification.failed_examples.count
end
def duration
@summary_notification.duration
end
def examples
@examples_notification.notifications
end
def result_of(notification)
notification.example.execution_result.status
end
def example_group_file_path_for(notification)
notification.example.example_group.file_path
end
def classname_for(notification)
fp = example_group_file_path_for(notification)
fp.sub(%r{\.[^/]*\Z}, "").gsub("/", ".").gsub(%r{\A\.+|\.+\Z}, "")
end
def duration_for(notification)
notification.example.execution_result.run_time
end
def description_for(notification)
notification.example.full_description
end
def exception_for(notification)
notification.example.execution_result.exception
end
def formatted_backtrace_for(notification)
notification.formatted_backtrace
end
end