luna-rspec-formatters 3.14.0 → 3.16.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/Gemfile +5 -4
- data/LICENSE +1 -1
- data/lib/luna-rspec-formatters.rb +2 -2
- data/lib/luna/rspec/formatters.rb +10 -9
- data/lib/luna/rspec/formatters/cats.rb +14 -21
- data/lib/luna/rspec/formatters/checks.rb +8 -18
- data/lib/luna/rspec/formatters/documentation.rb +71 -0
- data/lib/luna/rspec/formatters/emoji.rb +22 -19
- data/lib/luna/rspec/formatters/extras/profiling.rb +116 -0
- data/lib/luna/rspec/formatters/hearts.rb +39 -0
- data/lib/luna/rspec/formatters/smiles.rb +14 -21
- data/lib/luna/rspec/formatters/version.rb +2 -2
- metadata +25 -25
- data/lib/luna/rspec/formatters/docs.rb +0 -93
- data/lib/luna/rspec/formatters/heart.rb +0 -46
- data/lib/luna/rspec/formatters/profiling.rb +0 -114
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e69b4bcd61ebcf458f20b3b136db6a807327b35adfb4e20c56129c98572e2bf8
|
4
|
+
data.tar.gz: da8babf829c70fbd07baf466037b60ffc68b41f06b98728d11ba4c153462ad99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a33a278cb204c0e1877f9c8096d928b26de416cfe92abfdef3c81c8801c74b40ebb517ed837c45434646f2fb020e20b82f6b41c6567806e33c5cc1959dc163e1
|
7
|
+
data.tar.gz: 240aa02828c26e7677a57d5ea838b868c7393b7ebf978093c80791df84ca2484c6734df7db238c0a5dd896ddea241a5e0a6c53b72bf6fa5c611ad552f91891c7
|
data/Gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2015 -
|
2
|
+
# Copyright: 2015 - 2020 Jordon Bedwell - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
3
4
|
# Encoding: utf-8
|
4
5
|
|
5
|
-
source
|
6
|
+
source 'https://rubygems.org'
|
6
7
|
gemspec
|
7
8
|
|
8
|
-
gem
|
9
|
+
gem 'rake'
|
9
10
|
group :development do
|
10
|
-
gem
|
11
|
+
gem 'pry', require: false
|
11
12
|
end
|
data/LICENSE
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2015 -
|
2
|
+
# Copyright: 2015 - 2020 - MIT License
|
3
3
|
# Author: Jordon Bedwell
|
4
4
|
# Encoding: utf-8
|
5
5
|
|
6
|
-
require
|
7
|
-
require "rspec"
|
6
|
+
require 'rspec'
|
8
7
|
|
9
8
|
module Luna
|
10
9
|
module Formatters
|
11
10
|
ConsoleCodes = RSpec::Core::Formatters::ConsoleCodes
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
def self.register(name)
|
12
|
+
RSpec::Core::Formatters.register(
|
13
|
+
name, :start, :start_dump, :example_passed,
|
14
|
+
:example_pending, :example_failed,
|
15
|
+
:dump_profile
|
16
|
+
)
|
17
|
+
end
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
21
|
# Default formatter. I prefer this.
|
21
|
-
require_relative
|
22
|
+
require_relative 'formatters/checks'
|
@@ -1,46 +1,39 @@
|
|
1
1
|
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2015 -
|
2
|
+
# Copyright: 2015 - 2020 - MIT License
|
3
3
|
# Author: Jordon Bedwell
|
4
4
|
# Encoding: utf-8
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative 'emoji'
|
7
7
|
|
8
8
|
module Luna
|
9
9
|
module Formatters
|
10
10
|
class Cats < Emoji
|
11
|
-
Formatters.register self, :start, :start_dump, :example_passed,
|
12
|
-
:example_pending, :example_failed, :dump_profile
|
13
|
-
|
14
|
-
# --
|
15
|
-
# Passed.
|
16
|
-
# --
|
17
11
|
def example_passed(_)
|
18
12
|
newline_or_addup
|
19
|
-
output.print
|
20
|
-
|
13
|
+
output.print ' ', success_color(
|
14
|
+
"\u1F63B"
|
15
|
+
)
|
21
16
|
end
|
22
17
|
|
23
|
-
# --
|
24
|
-
# Failed.
|
25
|
-
# --
|
26
18
|
def example_failed(_)
|
27
19
|
newline_or_addup
|
28
|
-
output.print
|
29
|
-
|
20
|
+
output.print ' ', failure_color(
|
21
|
+
"\u1F63E"
|
22
|
+
)
|
30
23
|
end
|
31
24
|
|
32
|
-
# --
|
33
|
-
# Pending.
|
34
|
-
# --
|
35
25
|
def example_pending(_)
|
36
26
|
newline_or_addup
|
37
|
-
output.print
|
38
|
-
|
27
|
+
output.print ' ', pending_color(
|
28
|
+
"\u1F63F"
|
29
|
+
)
|
39
30
|
end
|
40
31
|
end
|
32
|
+
|
33
|
+
register Cats
|
41
34
|
end
|
42
35
|
end
|
43
36
|
|
44
37
|
RSpec.configure do |c|
|
45
|
-
c.formatter =
|
38
|
+
c.formatter = 'Luna::Formatters::Cats'
|
46
39
|
end
|
@@ -1,49 +1,39 @@
|
|
1
1
|
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2015 -
|
2
|
+
# Copyright: 2015 - 2020 - MIT License
|
3
3
|
# Author: Jordon Bedwell
|
4
4
|
# Encoding: utf-8
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative 'emoji'
|
7
7
|
|
8
8
|
module Luna
|
9
9
|
module Formatters
|
10
10
|
class Checks < Emoji
|
11
|
-
Formatters.register self, :start, :start_dump, :example_passed,
|
12
|
-
:example_pending, :example_failed, :dump_profile
|
13
|
-
|
14
|
-
# --
|
15
|
-
# Passed.
|
16
|
-
# --
|
17
11
|
def example_passed(_)
|
18
12
|
newline_or_addup
|
19
|
-
output.print
|
13
|
+
output.print ' ', success_color(
|
20
14
|
"\u2714"
|
21
15
|
)
|
22
16
|
end
|
23
17
|
|
24
|
-
# --
|
25
|
-
# Failed.
|
26
|
-
# --
|
27
18
|
def example_failed(_)
|
28
19
|
newline_or_addup
|
29
|
-
output.print
|
20
|
+
output.print ' ', failure_color(
|
30
21
|
"\u2718"
|
31
22
|
)
|
32
23
|
end
|
33
24
|
|
34
|
-
# --
|
35
|
-
# Pending.
|
36
|
-
# --
|
37
25
|
def example_pending(_)
|
38
26
|
newline_or_addup
|
39
|
-
output.print
|
27
|
+
output.print ' ', pending_color(
|
40
28
|
"\u203D"
|
41
29
|
)
|
42
30
|
end
|
43
31
|
end
|
32
|
+
|
33
|
+
register Checks
|
44
34
|
end
|
45
35
|
end
|
46
36
|
|
47
37
|
RSpec.configure do |c|
|
48
|
-
c.formatter =
|
38
|
+
c.formatter = 'Luna::Formatters::Checks'
|
49
39
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2015 - 2020 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
5
|
+
|
6
|
+
require_relative 'profiling'
|
7
|
+
require 'rspec/core/formatters/base_text_formatter'
|
8
|
+
require 'rspec/version'
|
9
|
+
|
10
|
+
module Luna
|
11
|
+
module Formatters
|
12
|
+
class Documentation < RSpec::Core::Formatters::BaseTextFormatter
|
13
|
+
include Profiling
|
14
|
+
|
15
|
+
%i(success failure pending).each do |m|
|
16
|
+
define_method "#{m}_color" do |v|
|
17
|
+
return super(v) if defined?(super)
|
18
|
+
RSpec::Core::Formatters::ConsoleCodes
|
19
|
+
.wrap(v, m)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def start(_)
|
24
|
+
output.puts
|
25
|
+
end
|
26
|
+
|
27
|
+
def start_dump(_)
|
28
|
+
output.puts
|
29
|
+
end
|
30
|
+
|
31
|
+
def example_passed(struct)
|
32
|
+
output.print "\s"
|
33
|
+
print_description(
|
34
|
+
get_example(struct), :success
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
def example_failed(struct)
|
39
|
+
output.print "\s"
|
40
|
+
print_description(
|
41
|
+
get_example(struct), :failure
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def example_pending(struct)
|
46
|
+
output.print "\s"
|
47
|
+
print_description(
|
48
|
+
get_example(struct), :pending
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_example(struct)
|
53
|
+
return struct unless struct.respond_to?(:example)
|
54
|
+
struct.example
|
55
|
+
end
|
56
|
+
|
57
|
+
def print_description(example, type)
|
58
|
+
desc = example.full_description
|
59
|
+
output.print send(
|
60
|
+
:"#{type}_color", ' ' + desc + "\n"
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
register Documentation
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
RSpec.configure do |c|
|
70
|
+
c.formatter = 'Luna::Formatters::Documentation'
|
71
|
+
end
|
@@ -1,19 +1,18 @@
|
|
1
|
-
# Frozen-
|
2
|
-
# Copyright: 2015 -
|
1
|
+
# Frozen-String-Literal: true
|
2
|
+
# Copyright: 2015 - 2020 - MIT License
|
3
3
|
# Author: Jordon Bedwell
|
4
4
|
# Encoding: utf-8
|
5
5
|
|
6
|
-
require
|
7
|
-
require_relative
|
8
|
-
require
|
9
|
-
require_relative
|
6
|
+
require 'io/console'
|
7
|
+
require_relative '../formatters'
|
8
|
+
require 'rspec/core/formatters/base_text_formatter'
|
9
|
+
require_relative 'extras/profiling'
|
10
10
|
|
11
11
|
module Luna
|
12
12
|
module Formatters
|
13
13
|
class Emoji < RSpec::Core::Formatters::BaseTextFormatter
|
14
14
|
include Profiling
|
15
15
|
|
16
|
-
# --
|
17
16
|
%i(success failure pending).each do |m|
|
18
17
|
define_method "#{m}_color" do |v|
|
19
18
|
return super(v) if defined?(super)
|
@@ -22,32 +21,34 @@ module Luna
|
|
22
21
|
end
|
23
22
|
|
24
23
|
# --
|
25
|
-
# Note: If the terminal is too small
|
26
|
-
# The total columns
|
24
|
+
# Note: If the terminal is too small
|
25
|
+
# we just let it go. The total columns
|
26
|
+
# we allow is just a example
|
27
27
|
# --
|
28
28
|
def allowed_cols
|
29
|
-
@
|
29
|
+
return @allowed_cols if defined?(@allowed_cols)
|
30
|
+
@allowed_cols ||= begin
|
31
|
+
infi = Float::INFINITY
|
32
|
+
size = IO.console&.winsize&.last
|
33
|
+
size = size || infi
|
34
|
+
size / 6
|
35
|
+
end
|
30
36
|
end
|
31
37
|
|
32
|
-
# --
|
33
|
-
# Start.
|
34
|
-
# --
|
35
38
|
def start(_)
|
36
39
|
@lines = 0
|
37
40
|
output.puts
|
38
41
|
end
|
39
42
|
|
40
|
-
# --
|
41
|
-
# End.
|
42
|
-
# --
|
43
43
|
def start_dump(_)
|
44
44
|
output.puts
|
45
45
|
end
|
46
46
|
|
47
47
|
# --
|
48
|
-
# Determine if we should start a new
|
49
|
-
# on pushing out. Note: if
|
50
|
-
# we just let
|
48
|
+
# Determine if we should start a new
|
49
|
+
# line or keep on pushing out. Note: if
|
50
|
+
# the terminal is too small we just let
|
51
|
+
# it go until it's done.
|
51
52
|
# --
|
52
53
|
private
|
53
54
|
def newline_or_addup
|
@@ -59,5 +60,7 @@ module Luna
|
|
59
60
|
@lines = 1
|
60
61
|
end
|
61
62
|
end
|
63
|
+
|
64
|
+
register Emoji
|
62
65
|
end
|
63
66
|
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2015 - 2020 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
5
|
+
|
6
|
+
module Luna
|
7
|
+
module Formatters
|
8
|
+
module Profiling
|
9
|
+
EXP = ' %<loc>s took %<sec>s'
|
10
|
+
GROUPS = ' %<loc>s took %<count>g for %<sec>s'
|
11
|
+
GROUPS_HEADER = "\nTop %<count>g slowest example groups:"
|
12
|
+
EXP_HEADER = "\nTop %<count>g slowest examples (%<sec>gs), "\
|
13
|
+
"%<percent>g%% of total time:\n"
|
14
|
+
|
15
|
+
def helpers
|
16
|
+
RSpec::Core::Formatters::Helpers
|
17
|
+
end
|
18
|
+
|
19
|
+
def dump_profile(profile)
|
20
|
+
slowest_examples(profile)
|
21
|
+
slowest_example_groups(
|
22
|
+
profile
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def slowest_examples(profile)
|
28
|
+
examples_header(profile)
|
29
|
+
|
30
|
+
profile.slowest_examples.map do |example|
|
31
|
+
r_time = example.execution_result.run_time
|
32
|
+
sec = helpers.format_seconds(
|
33
|
+
r_time
|
34
|
+
)
|
35
|
+
|
36
|
+
sec = sec + ' seconds'
|
37
|
+
@output.puts(
|
38
|
+
format(EXP, {
|
39
|
+
loc: format_caller(example.location),
|
40
|
+
sec: sec.to_f < 1 ? success_color(sec) : failure_color(sec),
|
41
|
+
dsc: example.full_description
|
42
|
+
})
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
def slowest_example_groups(profile)
|
49
|
+
groups_header(profile)
|
50
|
+
|
51
|
+
profile.slowest_groups.each do |l, h|
|
52
|
+
sec = helpers.format_seconds(
|
53
|
+
h[:total_time]
|
54
|
+
)
|
55
|
+
|
56
|
+
sec = sec + ' seconds'
|
57
|
+
@output.puts color_blue(
|
58
|
+
format(GROUPS, {
|
59
|
+
desc: h[:description],
|
60
|
+
sec: sec.to_f < 2 ? success_color(sec) : failure_color(sec),
|
61
|
+
count: h[:count],
|
62
|
+
loc: color_blue(
|
63
|
+
strip_relative(l)
|
64
|
+
)
|
65
|
+
})
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
def groups_header(profile)
|
72
|
+
@output.puts(
|
73
|
+
format(GROUPS_HEADER, {
|
74
|
+
count: profile.slowest_groups.size
|
75
|
+
})
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
def examples_header(profile)
|
81
|
+
@output.puts(
|
82
|
+
format(EXP_HEADER, {
|
83
|
+
count: profile.slowest_examples.size,
|
84
|
+
percent: profile.percentage,
|
85
|
+
sec: helpers.format_seconds(
|
86
|
+
profile.slow_duration
|
87
|
+
)
|
88
|
+
})
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
def color_blue(str)
|
94
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(
|
95
|
+
str, :cyan
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
def strip_relative(path)
|
101
|
+
path.gsub(
|
102
|
+
%r!\A\./!, ''
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
def format_caller(caller_info)
|
108
|
+
color_blue strip_relative(
|
109
|
+
::RSpec.configuration.backtrace_formatter.backtrace_line(
|
110
|
+
caller_info.to_s.split(":in `block'").first
|
111
|
+
)
|
112
|
+
)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Frozen-string-literal: true
|
2
|
+
# Copyright: 2015 - 2020 - MIT License
|
3
|
+
# Author: Jordon Bedwell
|
4
|
+
# Encoding: utf-8
|
5
|
+
|
6
|
+
require_relative 'emoji'
|
7
|
+
|
8
|
+
module Luna
|
9
|
+
module Formatters
|
10
|
+
class Hearts < Emoji
|
11
|
+
def example_passed(_)
|
12
|
+
newline_or_addup
|
13
|
+
output.print ' ', success_color(
|
14
|
+
"\u2764"
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def example_failed(_)
|
19
|
+
newline_or_addup
|
20
|
+
output.print ' ', failure_color(
|
21
|
+
"\u1F494"
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def example_pending(_)
|
26
|
+
newline_or_addup
|
27
|
+
output.print ' ', pending_color(
|
28
|
+
"\u2764"
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
register Hearts
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec.configure do |c|
|
38
|
+
c.formatter = 'Luna::Formatters::Hearts'
|
39
|
+
end
|
@@ -1,46 +1,39 @@
|
|
1
1
|
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2015 -
|
2
|
+
# Copyright: 2015 - 2020 - MIT License
|
3
3
|
# Author: Jordon Bedwell
|
4
4
|
# Encoding: utf-8
|
5
5
|
|
6
|
-
require_relative
|
6
|
+
require_relative 'emoji'
|
7
7
|
|
8
8
|
module Luna
|
9
9
|
module Formatters
|
10
10
|
class Smiles < Emoji
|
11
|
-
Formatters.register self, :start, :start_dump, :example_passed,
|
12
|
-
:example_pending, :example_failed, :dump_profile
|
13
|
-
|
14
|
-
# --
|
15
|
-
# Passed.
|
16
|
-
# --
|
17
11
|
def example_passed(_)
|
18
12
|
newline_or_addup
|
19
|
-
output.print
|
20
|
-
|
13
|
+
output.print ' ', success_color(
|
14
|
+
"\u263A"
|
15
|
+
)
|
21
16
|
end
|
22
17
|
|
23
|
-
# --
|
24
|
-
# Failed.
|
25
|
-
# --
|
26
18
|
def example_failed(_)
|
27
19
|
newline_or_addup
|
28
|
-
output.print
|
29
|
-
|
20
|
+
output.print ' ', failure_color(
|
21
|
+
"\u2639"
|
22
|
+
)
|
30
23
|
end
|
31
24
|
|
32
|
-
# --
|
33
|
-
# Pending.
|
34
|
-
# --
|
35
25
|
def example_pending(_)
|
36
26
|
newline_or_addup
|
37
|
-
output.print
|
38
|
-
|
27
|
+
output.print ' ', pending_color(
|
28
|
+
"\u2639"
|
29
|
+
)
|
39
30
|
end
|
40
31
|
end
|
32
|
+
|
33
|
+
register Smiles
|
41
34
|
end
|
42
35
|
end
|
43
36
|
|
44
37
|
RSpec.configure do |c|
|
45
|
-
c.formatter =
|
38
|
+
c.formatter = 'Luna::Formatters::Smilies'
|
46
39
|
end
|
metadata
CHANGED
@@ -1,63 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luna-rspec-formatters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.16.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: 2020-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: forwardable-extended
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.0'
|
20
|
-
- - "<"
|
17
|
+
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
19
|
+
version: '2.6'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3.0'
|
30
|
-
- - "<"
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
26
|
+
version: '2.6'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
28
|
+
name: rubocop
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
40
|
-
type: :
|
33
|
+
version: 0.80.1
|
34
|
+
type: :development
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
38
|
- - "~>"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
40
|
+
version: 0.80.1
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
42
|
+
name: rspec
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
45
|
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
|
47
|
+
version: '3.0'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '4.0'
|
51
|
+
type: :runtime
|
55
52
|
prerelease: false
|
56
53
|
version_requirements: !ruby/object:Gem::Requirement
|
57
54
|
requirements:
|
58
55
|
- - ">="
|
59
56
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
57
|
+
version: '3.0'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '4.0'
|
61
61
|
description: RSpec formatters that are dedicated to Luna.
|
62
62
|
email:
|
63
63
|
- jordon@envygeeks.io
|
@@ -72,10 +72,10 @@ files:
|
|
72
72
|
- lib/luna/rspec/formatters.rb
|
73
73
|
- lib/luna/rspec/formatters/cats.rb
|
74
74
|
- lib/luna/rspec/formatters/checks.rb
|
75
|
-
- lib/luna/rspec/formatters/
|
75
|
+
- lib/luna/rspec/formatters/documentation.rb
|
76
76
|
- lib/luna/rspec/formatters/emoji.rb
|
77
|
-
- lib/luna/rspec/formatters/
|
78
|
-
- lib/luna/rspec/formatters/
|
77
|
+
- lib/luna/rspec/formatters/extras/profiling.rb
|
78
|
+
- lib/luna/rspec/formatters/hearts.rb
|
79
79
|
- lib/luna/rspec/formatters/smiles.rb
|
80
80
|
- lib/luna/rspec/formatters/version.rb
|
81
81
|
homepage: https://github.com/envygeeks/luna-rspec-formatters
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
100
|
+
rubygems_version: 3.1.2
|
101
101
|
signing_key:
|
102
102
|
specification_version: 4
|
103
103
|
summary: RSpec formatters dedicated to Luna.
|
@@ -1,93 +0,0 @@
|
|
1
|
-
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2015 - 2018 - MIT License
|
3
|
-
# Author: Jordon Bedwell
|
4
|
-
# Encoding: utf-8
|
5
|
-
|
6
|
-
require_relative "profiling"
|
7
|
-
require "rspec/core/formatters/base_text_formatter"
|
8
|
-
require "rspec/version"
|
9
|
-
|
10
|
-
module Luna
|
11
|
-
module Formatters
|
12
|
-
class Documentation < RSpec::Core::Formatters::BaseTextFormatter
|
13
|
-
include Profiling
|
14
|
-
|
15
|
-
# --
|
16
|
-
Formatters.register self, :start, :start_dump, :example_passed,
|
17
|
-
:example_pending, :example_failed, :dump_profile
|
18
|
-
|
19
|
-
# --
|
20
|
-
%i(success failure pending).each do |m|
|
21
|
-
define_method "#{m}_color" do |v|
|
22
|
-
return super(v) if defined?(super)
|
23
|
-
RSpec::Core::Formatters::ConsoleCodes
|
24
|
-
.wrap(v, m)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# --
|
29
|
-
# Start.
|
30
|
-
# --
|
31
|
-
def start(_)
|
32
|
-
output.puts
|
33
|
-
end
|
34
|
-
|
35
|
-
# --
|
36
|
-
# End.
|
37
|
-
# --
|
38
|
-
def start_dump(_)
|
39
|
-
output.puts
|
40
|
-
end
|
41
|
-
|
42
|
-
# --
|
43
|
-
# Passed.
|
44
|
-
# --
|
45
|
-
def example_passed(struct)
|
46
|
-
output.print "\s"
|
47
|
-
print_description(get_example(struct),
|
48
|
-
:success)
|
49
|
-
end
|
50
|
-
|
51
|
-
# --
|
52
|
-
# Failed.
|
53
|
-
# --
|
54
|
-
def example_failed(struct)
|
55
|
-
output.print "\s"
|
56
|
-
print_description(get_example(struct),
|
57
|
-
:failure)
|
58
|
-
end
|
59
|
-
|
60
|
-
# --
|
61
|
-
# Pending.
|
62
|
-
# --
|
63
|
-
def example_pending(struct)
|
64
|
-
output.print "\s"
|
65
|
-
print_description(get_example(struct),
|
66
|
-
:pending)
|
67
|
-
end
|
68
|
-
|
69
|
-
# --
|
70
|
-
# Pull.
|
71
|
-
# --
|
72
|
-
def get_example(struct)
|
73
|
-
unless struct.respond_to?(:example)
|
74
|
-
return struct
|
75
|
-
end
|
76
|
-
|
77
|
-
struct.example
|
78
|
-
end
|
79
|
-
|
80
|
-
# --
|
81
|
-
# Description.
|
82
|
-
# --
|
83
|
-
def print_description(example, type)
|
84
|
-
output.print send(:"#{type}_color", " " +
|
85
|
-
example.full_description + "\n")
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
RSpec.configure do |c|
|
92
|
-
c.formatter = "Luna::Formatters::Documentation"
|
93
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2015 - 2018 - MIT License
|
3
|
-
# Author: Jordon Bedwell
|
4
|
-
# Encoding: utf-8
|
5
|
-
|
6
|
-
require_relative "emoji"
|
7
|
-
|
8
|
-
module Luna
|
9
|
-
module Formatters
|
10
|
-
class Hearts < Emoji
|
11
|
-
Formatters.register self, :start, :start_dump, :example_passed,
|
12
|
-
:example_pending, :example_failed, :dump_profile
|
13
|
-
|
14
|
-
# --
|
15
|
-
# Passed.
|
16
|
-
# --
|
17
|
-
def example_passed(_)
|
18
|
-
newline_or_addup
|
19
|
-
output.print " ",
|
20
|
-
success_color("\u2764")
|
21
|
-
end
|
22
|
-
|
23
|
-
# --
|
24
|
-
# Failed.
|
25
|
-
# --
|
26
|
-
def example_failed(_)
|
27
|
-
newline_or_addup
|
28
|
-
output.print " ",
|
29
|
-
failure_color("\u1F494")
|
30
|
-
end
|
31
|
-
|
32
|
-
# --
|
33
|
-
# Pending.
|
34
|
-
# --
|
35
|
-
def example_pending(_)
|
36
|
-
newline_or_addup
|
37
|
-
output.print " ",
|
38
|
-
pending_color("\u2764")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
RSpec.configure do |c|
|
45
|
-
c.formatter = "Luna::Formatters::Hearts"
|
46
|
-
end
|
@@ -1,114 +0,0 @@
|
|
1
|
-
# Frozen-string-literal: true
|
2
|
-
# Copyright: 2015 - 2018 - MIT License
|
3
|
-
# Author: Jordon Bedwell
|
4
|
-
# Encoding: utf-8
|
5
|
-
|
6
|
-
module Luna
|
7
|
-
module Formatters
|
8
|
-
module Profiling
|
9
|
-
EXP = " %<loc>s took %<sec>s"
|
10
|
-
GROUPS = " %<loc>s took %<count>g for %<sec>s"
|
11
|
-
GROUPS_HEADER = "\nTop %<count>g slowest example groups:"
|
12
|
-
EXP_HEADER = "\nTop %<count>g slowest examples (%<sec>gs), "\
|
13
|
-
"%<percent>g%% of total time:\n"
|
14
|
-
|
15
|
-
# --
|
16
|
-
# Help.
|
17
|
-
# --
|
18
|
-
def helpers
|
19
|
-
RSpec::Core::Formatters::Helpers
|
20
|
-
end
|
21
|
-
|
22
|
-
# --
|
23
|
-
# Profile.
|
24
|
-
# --
|
25
|
-
def dump_profile(profile)
|
26
|
-
dump_profile_slowest_examples(profile)
|
27
|
-
dump_profile_slowest_example_groups(
|
28
|
-
profile
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
# --
|
33
|
-
# Slow examples.
|
34
|
-
# --
|
35
|
-
private
|
36
|
-
def dump_profile_slowest_examples(profile)
|
37
|
-
examples_header(profile)
|
38
|
-
|
39
|
-
profile.slowest_examples.each do |e|
|
40
|
-
sec = helpers.format_seconds(e.execution_result.run_time)
|
41
|
-
sec = sec + " seconds"
|
42
|
-
|
43
|
-
@output.puts format(EXP, {
|
44
|
-
loc: format_caller(e.location),
|
45
|
-
sec: sec.to_f < 1 ? success_color(sec) : failure_color(sec),
|
46
|
-
desc: e.full_description,
|
47
|
-
})
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# --
|
52
|
-
# Slowest example groups.
|
53
|
-
# --
|
54
|
-
private
|
55
|
-
def dump_profile_slowest_example_groups(profile)
|
56
|
-
groups_header(profile)
|
57
|
-
|
58
|
-
profile.slowest_groups.each do |l, h|
|
59
|
-
sec = helpers.format_seconds(h[:total_time])
|
60
|
-
sec = sec + " seconds"
|
61
|
-
|
62
|
-
@output.puts color_blue(format(GROUPS, {
|
63
|
-
desc: h[:description],
|
64
|
-
sec: sec.to_f < 2 ? success_color(sec) : failure_color(sec),
|
65
|
-
loc: color_blue(strip_relative(l)),
|
66
|
-
count: h[:count],
|
67
|
-
}))
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# --
|
72
|
-
# Headers group.
|
73
|
-
# --
|
74
|
-
private
|
75
|
-
def groups_header(profile)
|
76
|
-
@output.puts format(GROUPS_HEADER, {
|
77
|
-
count: profile.slowest_groups.size,
|
78
|
-
})
|
79
|
-
end
|
80
|
-
|
81
|
-
# --
|
82
|
-
# Header example.
|
83
|
-
# --
|
84
|
-
private
|
85
|
-
def examples_header(profile)
|
86
|
-
@output.puts format(EXP_HEADER, {
|
87
|
-
count: profile.slowest_examples.size,
|
88
|
-
sec: helpers.format_seconds(profile.slow_duration),
|
89
|
-
percent: profile.percentage,
|
90
|
-
})
|
91
|
-
end
|
92
|
-
|
93
|
-
# --
|
94
|
-
private
|
95
|
-
def color_blue(str)
|
96
|
-
RSpec::Core::Formatters::ConsoleCodes
|
97
|
-
.wrap(str, :cyan)
|
98
|
-
end
|
99
|
-
|
100
|
-
# --
|
101
|
-
private
|
102
|
-
def strip_relative(path)
|
103
|
-
path.gsub(%r!\A\./!, "")
|
104
|
-
end
|
105
|
-
|
106
|
-
# --
|
107
|
-
private
|
108
|
-
def format_caller(caller_info)
|
109
|
-
color_blue strip_relative(::RSpec.configuration.backtrace_formatter
|
110
|
-
.backtrace_line(caller_info.to_s.split(":in `block'").first))
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|