luna-rspec-formatters 1.2.2 → 2.0.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2a72592d7af145adca7aaa455ec35485c3f34b4
|
4
|
+
data.tar.gz: b5fda1869548cb2e6b0443fa332171cce402eb11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40cccc65b71fc100bc71c0e35198352c42cbb81f71cb0004bb29f1456129b0b73738ac5f185932bc3f129afbdaf32fdfb2811ecf974f3cc867e572ed3a2d43ae
|
7
|
+
data.tar.gz: 180e7c29828e7aa37bae850c1213d2acfb09d2025803d61409fe2728aad313763b7c212118e15faec90bc3da6989ee5bd4bdf3a55c7c4359857a8fb1e964a500
|
@@ -1,18 +1,19 @@
|
|
1
1
|
require "rspec/core/formatters/base_text_formatter"
|
2
|
+
require "luna/rspec/formatters/profile"
|
2
3
|
require "rspec/version"
|
3
4
|
|
4
5
|
module Luna
|
5
6
|
module RSpec
|
6
7
|
module Formatters
|
7
8
|
class Checks < ::RSpec::Core::Formatters::BaseTextFormatter
|
9
|
+
include Profile
|
10
|
+
|
8
11
|
if ::RSpec::Version::STRING >= "3.0.0"
|
9
12
|
# Probably not available in the old version of RSpec.
|
10
|
-
::RSpec::Core::Formatters.register self, :start, :start_dump, \
|
11
|
-
:example_passed, :example_pending, :example_failed
|
13
|
+
then ::RSpec::Core::Formatters.register self, :start, :start_dump, \
|
14
|
+
:example_passed, :example_pending, :example_failed, :dump_profile
|
12
15
|
end
|
13
16
|
|
14
|
-
# ---------------------------------------------------------------------
|
15
|
-
|
16
17
|
[:success, :failure, :pending].each do |m|
|
17
18
|
define_method "#{m}_color" do |v|
|
18
19
|
defined?(super) ? super(v) : \
|
@@ -20,38 +21,28 @@ module Luna
|
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
|
-
# ---------------------------------------------------------------------
|
24
|
-
|
25
24
|
def start(*args)
|
26
25
|
super(*args) if defined?(super)
|
27
26
|
output.puts
|
28
27
|
end
|
29
28
|
|
30
|
-
# ---------------------------------------------------------------------
|
31
|
-
|
32
29
|
def start_dump(*args)
|
33
30
|
super(*args) if defined?(super)
|
34
31
|
output.puts
|
35
32
|
end
|
36
33
|
|
37
|
-
# ---------------------------------------------------------------------
|
38
|
-
|
39
34
|
def example_passed(e)
|
40
35
|
super(e) if defined?(super)
|
41
36
|
output.print("\s")
|
42
37
|
output.print(success_color("\u2713"))
|
43
38
|
end
|
44
39
|
|
45
|
-
# ---------------------------------------------------------------------
|
46
|
-
|
47
40
|
def example_failed(e)
|
48
41
|
super(e) if defined?(super)
|
49
42
|
output.print("\s")
|
50
43
|
output.print(failure_color("\u2718"))
|
51
44
|
end
|
52
45
|
|
53
|
-
# ---------------------------------------------------------------------
|
54
|
-
|
55
46
|
def example_pending(e)
|
56
47
|
super(e) if defined?(super)
|
57
48
|
output.print("\s")
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "rspec/core/formatters/base_text_formatter"
|
2
|
+
require "luna/rspec/formatters/formatters/profile"
|
2
3
|
require "rspec/version"
|
3
4
|
require "coderay"
|
4
5
|
|
@@ -6,14 +7,14 @@ module Luna
|
|
6
7
|
module RSpec
|
7
8
|
module Formatters
|
8
9
|
class Documentation < ::RSpec::Core::Formatters::BaseTextFormatter
|
10
|
+
include Profile
|
11
|
+
|
9
12
|
if ::RSpec::Version::STRING >= "3.0.0"
|
10
13
|
# Probably not available in the old version of RSpec.
|
11
14
|
::RSpec::Core::Formatters.register self, :start, :start_dump, \
|
12
|
-
:example_passed, :example_pending, :example_failed
|
15
|
+
:example_passed, :example_pending, :example_failed, :dump_profile
|
13
16
|
end
|
14
17
|
|
15
|
-
# ---------------------------------------------------------------------
|
16
|
-
|
17
18
|
[:success, :failure, :pending].each do |m|
|
18
19
|
define_method "#{m}_color" do |v|
|
19
20
|
defined?(super) ? super(v) : \
|
@@ -21,43 +22,31 @@ module Luna
|
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
# ---------------------------------------------------------------------
|
25
|
-
|
26
25
|
def start(*args)
|
27
26
|
super(*args) if defined?(super)
|
28
27
|
output.puts
|
29
28
|
end
|
30
29
|
|
31
|
-
# ---------------------------------------------------------------------
|
32
|
-
|
33
30
|
def start_dump(*args)
|
34
31
|
super(*args) if defined?(super)
|
35
32
|
output.puts
|
36
33
|
end
|
37
34
|
|
38
|
-
# ---------------------------------------------------------------------
|
39
|
-
|
40
35
|
def example_passed(e)
|
41
36
|
output.print("\s")
|
42
37
|
print_description(e, :success)
|
43
38
|
end
|
44
39
|
|
45
|
-
# ---------------------------------------------------------------------
|
46
|
-
|
47
40
|
def example_failed(e)
|
48
41
|
output.print("\s")
|
49
42
|
print_description(e, :failure)
|
50
43
|
end
|
51
44
|
|
52
|
-
# ---------------------------------------------------------------------
|
53
|
-
|
54
45
|
def example_pending(e)
|
55
46
|
output.print("\s")
|
56
47
|
print_description(e, :pending)
|
57
48
|
end
|
58
49
|
|
59
|
-
# ---------------------------------------------------------------------
|
60
|
-
|
61
50
|
def print_description(example, type)
|
62
51
|
output.print send(:"#{type}_color",
|
63
52
|
"\t" + example.full_description + "\n")
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# This is exactly the same as RSpec except I removed a lot of the "\n" cruft.
|
2
|
+
|
3
|
+
module Luna
|
4
|
+
module RSpec
|
5
|
+
module Formatters
|
6
|
+
module Profile
|
7
|
+
def helpers
|
8
|
+
::RSpec::Core::Formatters::Helpers
|
9
|
+
end
|
10
|
+
|
11
|
+
def dump_profile(profile)
|
12
|
+
dump_profile_slowest_examples(profile)
|
13
|
+
dump_profile_slowest_example_groups(profile)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
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"
|
24
|
+
|
25
|
+
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}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
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
|
+
|
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")
|
42
|
+
|
43
|
+
@output.puts " #{h[:description]} #{average} (#{total} / #{count}) #{l}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def bold(text)
|
48
|
+
::RSpec::Core::Formatters::ConsoleCodes.wrap(text, :bold)
|
49
|
+
end
|
50
|
+
|
51
|
+
def format_caller(caller_info)
|
52
|
+
::RSpec.configuration.backtrace_formatter.backtrace_line(
|
53
|
+
caller_info.to_s.split(':in `block').first
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luna-rspec-formatters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordon Bedwell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- Readme.md
|
43
43
|
- lib/luna/rspec/formatters/checks.rb
|
44
44
|
- lib/luna/rspec/formatters/documentation.rb
|
45
|
+
- lib/luna/rspec/formatters/profile.rb
|
45
46
|
- lib/luna/rspec/formatters/version.rb
|
46
47
|
homepage: https://github.com/envygeeks/luna-rspec-formatters
|
47
48
|
licenses:
|