luna-rspec-formatters 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2a72592d7af145adca7aaa455ec35485c3f34b4
4
- data.tar.gz: b5fda1869548cb2e6b0443fa332171cce402eb11
3
+ metadata.gz: 13ffc60847eba9e648ef2844fcda2f565b103fc9
4
+ data.tar.gz: cca05c85ca50436bf60176e437791906c63dd8be
5
5
  SHA512:
6
- metadata.gz: 40cccc65b71fc100bc71c0e35198352c42cbb81f71cb0004bb29f1456129b0b73738ac5f185932bc3f129afbdaf32fdfb2811ecf974f3cc867e572ed3a2d43ae
7
- data.tar.gz: 180e7c29828e7aa37bae850c1213d2acfb09d2025803d61409fe2728aad313763b7c212118e15faec90bc3da6989ee5bd4bdf3a55c7c4359857a8fb1e964a500
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
- size = profile.slowest_examples.size
19
- seconds = helpers.format_seconds(profile.slow_duration)
20
- per_cent = profile.percentage
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
- location = format_caller(e.location)
27
- seconds = helpers.format_seconds(e.execution_result.run_time)
28
- @output.puts " #{e.full_description} " \
29
- "#{bold(seconds)} #{bold("seconds")} #{location}"
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
- return if profile.slowest_groups.empty?
35
- @output.puts "\nTop #{profile.slowest_groups.size} " \
36
- "slowest example groups:"
37
+ unless !profile.slowest_groups.empty? && \
38
+ profile.slowest_groups.any? { |l, h| h[:average] >= 0.4 }
37
39
 
38
- profile.slowest_groups.each do |l, h|
39
- total = "#{helpers.format_seconds(h[:total_time])} seconds"
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
- @output.puts " #{h[:description]} #{average} (#{total} / #{count}) #{l}"
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 bold(text)
48
- ::RSpec::Core::Formatters::ConsoleCodes.wrap(text, :bold)
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)
@@ -1,7 +1,7 @@
1
1
  module Luna
2
2
  module Rspec
3
3
  module Formatters
4
- VERSION = "2.0.0"
4
+ VERSION = "2.1.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luna-rspec-formatters
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordon Bedwell