luna-rspec-formatters 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/luna/rspec/formatters/profile.rb +39 -22
- data/lib/luna/rspec/formatters/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13ffc60847eba9e648ef2844fcda2f565b103fc9
|
4
|
+
data.tar.gz: cca05c85ca50436bf60176e437791906c63dd8be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1b959dab6ad88192fc1617d269a417f9245a9b81ed8888465ef53e0d82de52c0bb4b44130c2befa238f9132a1d24ad816b354d1c881740d264b2b3d16345472
|
7
|
+
data.tar.gz: 33012551ddba831a5834b504953c9e3789a8dc51a64ea482021556cc2b5eb8147f0088fa35b2d32a9331c753a6663f2ba49c2c0518eb21c27eea824e10f6a8d6
|
@@ -1,9 +1,13 @@
|
|
1
|
-
# This is exactly the same as RSpec except I removed a lot of the "\n" cruft.
|
2
|
-
|
3
1
|
module Luna
|
4
2
|
module RSpec
|
5
3
|
module Formatters
|
6
4
|
module Profile
|
5
|
+
EXAMPLES = " %{description} %{seconds} seconds: %{location}"
|
6
|
+
GROUPS = " %{description} %{total} seconds over %{count} examples: %{location}"
|
7
|
+
EXAMPLES_HEADER = "\nTop %{size} slowest examples (%{seconds}s), %{per_cent}%% of total time:\n"
|
8
|
+
GROUPS_HEADER = "\nTop %{size} slowest example groups:"
|
9
|
+
|
10
|
+
|
7
11
|
def helpers
|
8
12
|
::RSpec::Core::Formatters::Helpers
|
9
13
|
end
|
@@ -15,37 +19,50 @@ module Luna
|
|
15
19
|
|
16
20
|
private
|
17
21
|
def dump_profile_slowest_examples(profile)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@output.puts "\nTop #{size} slowest examples (#{seconds}s), " \
|
23
|
-
"#{per_cent}% of total time):\n"
|
22
|
+
unless profile.slowest_examples.any? { |e| e.execution_result.run_time >= 0.2 }
|
23
|
+
return
|
24
|
+
end
|
24
25
|
|
26
|
+
examples_header(profile)
|
25
27
|
profile.slowest_examples.each do |e|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
@output.puts EXAMPLES % {
|
29
|
+
location: format_caller(e.location),
|
30
|
+
seconds: failure_color(helpers.format_seconds(e.execution_result.run_time)),
|
31
|
+
description: e.full_description
|
32
|
+
}
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
def dump_profile_slowest_example_groups(profile)
|
34
|
-
|
35
|
-
|
36
|
-
"slowest example groups:"
|
37
|
+
unless !profile.slowest_groups.empty? && \
|
38
|
+
profile.slowest_groups.any? { |l, h| h[:average] >= 0.4 }
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
average = "#{bold(helpers.format_seconds(h[:average]))} #{bold("seconds")} average"
|
41
|
-
count = helpers.pluralize(h[:count], "example")
|
40
|
+
return
|
41
|
+
end
|
42
42
|
|
43
|
-
|
43
|
+
groups_header(profile)
|
44
|
+
profile.slowest_groups.each do |l, h|
|
45
|
+
@output.puts GROUPS % {
|
46
|
+
description: h[:description],
|
47
|
+
total: failure_color(helpers.format_seconds(h[:total_time])),
|
48
|
+
count: helpers.pluralize(h[:count], "example"),
|
49
|
+
location: l
|
50
|
+
}
|
44
51
|
end
|
45
52
|
end
|
46
53
|
|
47
|
-
def
|
48
|
-
|
54
|
+
def groups_header(profile)
|
55
|
+
@output.puts GROUPS_HEADER % {
|
56
|
+
size: profile.slowest_groups.size
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def examples_header(profile)
|
61
|
+
@output.puts EXAMPLES_HEADER % {
|
62
|
+
size: profile.slowest_examples.size,
|
63
|
+
seconds: helpers.format_seconds(profile.slow_duration),
|
64
|
+
per_cent: profile.percentage
|
65
|
+
}
|
49
66
|
end
|
50
67
|
|
51
68
|
def format_caller(caller_info)
|