luna-rspec-formatters 3.8.1 → 3.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 642c2541c09a831c4bdff8fe4de598b642f99dc0
4
- data.tar.gz: 2997aa9603424bb6f5d339f025f9469fd68ce1ad
3
+ metadata.gz: fb75e1a08b92660aa145de699b8ebae578ae70b8
4
+ data.tar.gz: a95322897dbef02274a6621bdd33ce1561395976
5
5
  SHA512:
6
- metadata.gz: 36d69af354c5191eb2e1a0a8fcfb92bdcb13e1fb0eb7dfcfd7782b3e8a5756f318e221c0110757f39496172dd7afe323ae90d8e820796402acc805fcb820f476
7
- data.tar.gz: eac206450f2df4309badb0dca83aab3c227d7466ee51f51ab70eaef2b99537325e420fcfe22fb2cf12c636e571378a95a84ffd9fd6c44c4f9c1be601575ce985
6
+ metadata.gz: 8836bca51153a8746021c8a51a8dfb85e1e5bdf2ff16f251ddbf755a41086513b70adcf97bc970535c0957acc99d5ba6a951d4462ccc796dd7aeea6fd42fb970
7
+ data.tar.gz: 10508f5d90c3fc61c7b6ccd51bcd6376dbd71129a8957453ee8a1f6042df3187ceb64bb4f7e3235ad154c6da3f670cc5dc7c82a2d315a4294f62b5fcd126f19a
data/Gemfile CHANGED
@@ -1,14 +1,10 @@
1
- # ----------------------------------------------------------------------------
2
1
  # Frozen-string-literal: true
3
2
  # Copyright: 2015 - 2017 Jordon Bedwell - MIT License
4
3
  # Encoding: utf-8
5
- # ----------------------------------------------------------------------------
6
4
 
7
5
  source "https://rubygems.org"
8
6
  gemspec
9
7
 
10
8
  gem "rake"
11
- group :development do
12
- gem "rubocop", :github => "bbatsov/rubocop", :require => false
13
- gem "pry", :require => false
14
- end
9
+ gem "rubocop", require: false
10
+ gem "pry", require: false
@@ -0,0 +1,16 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2015 - 2017 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ require "rspec/core/formatters"
6
+ require "forwardable/extended"
7
+
8
+ module Luna
9
+ module Formatters
10
+ ConsoleCodes = RSpec::Core::Formatters::ConsoleCodes
11
+ extend Forwardable::Extended
12
+ rb_delegate :"self.register", {
13
+ to: :"RSpec::Core::Formatters", alias_of: :register
14
+ }
15
+ end
16
+ end
@@ -2,57 +2,44 @@
2
2
  # Copyright: 2015 - 2017 Jordon Bedwell - MIT License
3
3
  # Encoding: utf-8
4
4
 
5
- require "luna/rspec/formatters/emoji"
5
+ require_relative "emoji"
6
6
 
7
7
  module Luna
8
- module RSpec
9
- module Formatters
10
- class Smilies < Emoji
11
- if Gem::Version.new(Object::RSpec::Version::STRING) >= Gem::Version.new("3.0")
12
- then Object::RSpec::Core::Formatters.register self, *[
13
- :start,
14
- :start_dump,
15
- :example_passed,
16
- :example_pending,
17
- :example_failed,
18
- :dump_profile
19
- ]
20
- end
8
+ module Formatters
9
+ class Cats < Emoji
10
+ Formatters.register self, :start, :start_dump, :example_passed,
11
+ :example_pending, :example_failed, :dump_profile
21
12
 
22
- # --
23
- # Passed.
24
- # --
25
- def example_passed(_)
26
- newline_or_addup
27
- output.print " ".freeze, success_color(
28
- "\u1F63B"
29
- )
30
- end
13
+ # --
14
+ # Passed.
15
+ # --
16
+ def example_passed(_)
17
+ newline_or_addup
18
+ output.print " ", success_color(
19
+ "\u1F63B")
20
+ end
31
21
 
32
- # --
33
- # Failed.
34
- # --
35
- def example_failed(_)
36
- newline_or_addup
37
- output.print " ".freeze, failure_color(
38
- "\u1F63E"
39
- )
40
- end
22
+ # --
23
+ # Failed.
24
+ # --
25
+ def example_failed(_)
26
+ newline_or_addup
27
+ output.print " ", failure_color(
28
+ "\u1F63E")
29
+ end
41
30
 
42
- # --
43
- # Pending.
44
- # --
45
- def example_pending(_)
46
- newline_or_addup
47
- output.print " ".freeze, pending_color(
48
- "\u1F63F"
49
- )
50
- end
31
+ # --
32
+ # Pending.
33
+ # --
34
+ def example_pending(_)
35
+ newline_or_addup
36
+ output.print " ", pending_color(
37
+ "\u1F63F")
51
38
  end
52
39
  end
53
40
  end
54
41
  end
55
42
 
56
- RSpec.configure do |config|
57
- config.formatter = "Luna::RSpec::Formatters::Smilies"
43
+ RSpec.configure do |c|
44
+ c.formatter = "Luna::Formatters::Cats"
58
45
  end
@@ -2,59 +2,47 @@
2
2
  # Copyright: 2015 - 2017 Jordon Bedwell - MIT License
3
3
  # Encoding: utf-8
4
4
 
5
- require "luna/rspec/formatters/emoji"
5
+ require_relative "emoji"
6
6
 
7
7
  module Luna
8
- module RSpec
9
- module Formatters
10
- class Checks < Emoji
11
- include Profile
8
+ module Formatters
9
+ class Checks < Emoji
10
+ Formatters.register self, :start, :start_dump, :example_passed,
11
+ :example_pending, :example_failed, :dump_profile
12
12
 
13
- if Gem::Version.new(Object::RSpec::Version::STRING) >= Gem::Version.new("3.0")
14
- then Object::RSpec::Core::Formatters.register self, *[
15
- :start,
16
- :start_dump,
17
- :example_passed,
18
- :example_pending,
19
- :example_failed,
20
- :dump_profile
21
- ]
22
- end
23
-
24
- # --
25
- # Passed.
26
- # --
27
- def example_passed(_)
28
- newline_or_addup
29
- output.print " ".freeze, success_color(
30
- "\u2714"
31
- )
32
- end
13
+ # --
14
+ # Passed.
15
+ # --
16
+ def example_passed(_)
17
+ newline_or_addup
18
+ output.print " ".freeze, success_color(
19
+ "\u2714"
20
+ )
21
+ end
33
22
 
34
- # --
35
- # Failed.
36
- # --
37
- def example_failed(_)
38
- newline_or_addup
39
- output.print " ".freeze, failure_color(
40
- "\u2718"
41
- )
42
- end
23
+ # --
24
+ # Failed.
25
+ # --
26
+ def example_failed(_)
27
+ newline_or_addup
28
+ output.print " ".freeze, failure_color(
29
+ "\u2718"
30
+ )
31
+ end
43
32
 
44
- # --
45
- # Pending.
46
- # --
47
- def example_pending(_)
48
- newline_or_addup
49
- output.print " ".freeze, pending_color(
50
- "\u203D"
51
- )
52
- end
33
+ # --
34
+ # Pending.
35
+ # --
36
+ def example_pending(_)
37
+ newline_or_addup
38
+ output.print " ".freeze, pending_color(
39
+ "\u203D"
40
+ )
53
41
  end
54
42
  end
55
43
  end
56
44
  end
57
45
 
58
- RSpec.configure do |config|
59
- config.formatter = "Luna::RSpec::Formatters::Checks"
46
+ RSpec.configure do |c|
47
+ c.formatter = "Luna::Formatters::Checks"
60
48
  end
@@ -0,0 +1,93 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2015 - 2017 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ require_relative "profiling"
6
+ require "rspec/core/formatters/base_text_formatter"
7
+ require "rspec/version"
8
+
9
+ module Luna
10
+ module Formatters
11
+ class Documentation < RSpec::Core::Formatters::BaseTextFormatter
12
+ include Profiling
13
+
14
+ # --
15
+ Formatters.register self, :start, :start_dump, :example_passed,
16
+ :example_pending, :example_failed, :dump_profile
17
+
18
+ # --
19
+ [:success, :failure, :pending].each do |m|
20
+ define_method "#{m}_color" do |v|
21
+ return super(v) if defined?(super)
22
+ RSpec::Core::Formatters::ConsoleCodes.
23
+ wrap(v, m)
24
+ end
25
+ end
26
+
27
+ # --
28
+ # Start.
29
+ # --
30
+ def start(_)
31
+ output.puts
32
+ end
33
+
34
+ # --
35
+ # End.
36
+ # --
37
+ def start_dump(_)
38
+ output.puts
39
+ end
40
+
41
+ # --
42
+ # Passed.
43
+ # --
44
+ def example_passed(struct)
45
+ output.print "\s"
46
+ print_description(
47
+ get_example(struct), :success
48
+ )
49
+ end
50
+
51
+ # --
52
+ # Failed.
53
+ # --
54
+ def example_failed(struct)
55
+ output.print "\s"
56
+ print_description(
57
+ get_example(struct), :failure
58
+ )
59
+ end
60
+
61
+ # --
62
+ # Pending.
63
+ # --
64
+ def example_pending(struct)
65
+ output.print "\s"
66
+ print_description(
67
+ get_example(struct), :pending
68
+ )
69
+ end
70
+
71
+ # --
72
+ # Pull.
73
+ # --
74
+ def get_example(struct)
75
+ return struct unless struct.respond_to?(:example)
76
+ struct.example
77
+ end
78
+
79
+ # --
80
+ # Description.
81
+ # --
82
+ def print_description(example, type)
83
+ output.print send(
84
+ :"#{type}_color", " " + example.full_description + "\n"
85
+ )
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ RSpec.configure do |c|
92
+ config.formatter = "Luna::Formatters::Documentation"
93
+ end
@@ -3,57 +3,62 @@
3
3
  # Encoding: utf-8
4
4
 
5
5
  require "io/console"
6
+ require_relative "../formatters"
6
7
  require "rspec/core/formatters/base_text_formatter"
7
- require "luna/rspec/formatters/profile"
8
- require "rspec/version"
8
+ require_relative "profiling"
9
9
 
10
10
  module Luna
11
- module RSpec
12
- module Formatters
13
- class Emoji < ::RSpec::Core::Formatters::BaseTextFormatter
14
- include Profile
15
-
16
- [:success, :failure, :pending].each do |m|
17
- define_method "#{m}_color" do |v|
18
- return super(v) if defined?(super)
19
- Object::RSpec::Core::Formatters::ConsoleCodes.wrap(v, m)
20
- end
21
- end
11
+ module Formatters
12
+ class Emoji < RSpec::Core::Formatters::BaseTextFormatter
13
+ include Profiling
22
14
 
23
- # --
24
- # Note: If the terminal is too small we just let it go.
25
- # The total columns we allow.
26
- # --
27
- def allowed_cols
28
- @cols ||= begin
29
- (val = IO.console.winsize.last / 4) >= 24 ? val.floor : Float::INFINITY
30
- end
15
+ # --
16
+ [:success, :failure, :pending].each do |m|
17
+ define_method "#{m}_color" do |v|
18
+ return super(v) if defined?(super)
19
+ Formatters::ConsoleCodes.wrap(v, m)
31
20
  end
21
+ end
32
22
 
33
- # --
34
- # Start.
35
- # --
36
- def start(_)
37
- @lines = 0
38
- output.puts
23
+ # --
24
+ # Note: If the terminal is too small we just let it go.
25
+ # The total columns we allow.
26
+ # --
27
+ def allowed_cols
28
+ @cols ||= begin
29
+ (val = IO.console.winsize.last / 4) >= 24 ? val.floor :
30
+ Float::INFINITY
39
31
  end
32
+ end
40
33
 
41
- # --
42
- # End.
43
- # --
44
- def start_dump(_)
45
- output.puts
46
- end
34
+ # --
35
+ # Start.
36
+ # --
37
+ def start(_)
38
+ @lines = 0
39
+ output.puts
40
+ end
41
+
42
+ # --
43
+ # End.
44
+ # --
45
+ def start_dump(_)
46
+ output.puts
47
+ end
47
48
 
48
- # --
49
- # Determine if we should start a new line or keep on pushing out.
50
- # Note: if the terminal is too small we just let it go.
51
- # --
52
- private
53
- def newline_or_addup
54
- return @lines+= 1 unless @lines == allowed_cols
55
- output.puts; @lines = 1
49
+ # --
50
+ # Determine if we should start a new line or keep
51
+ # on pushing out. Note: if the terminal is too small
52
+ # we just let it go.
53
+ # --
54
+ private
55
+ def newline_or_addup
56
+ unless @lines == allowed_cols
57
+ return @lines+= 1
56
58
  end
59
+
60
+ output.puts
61
+ @lines = 1
57
62
  end
58
63
  end
59
64
  end
@@ -0,0 +1,48 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2015 - 2017 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ require_relative "emoji"
6
+
7
+ module Luna
8
+ module Formatters
9
+ class Hearts < Emoji
10
+ Formatters.register self, :start, :start_dump, :example_passed,
11
+ :example_pending, :example_failed, :dump_profile
12
+
13
+ # --
14
+ # Passed.
15
+ # --
16
+ def example_passed(_)
17
+ newline_or_addup
18
+ output.print " ".freeze, success_color(
19
+ "\u2764"
20
+ )
21
+ end
22
+
23
+ # --
24
+ # Failed.
25
+ # --
26
+ def example_failed(_)
27
+ newline_or_addup
28
+ output.print " ".freeze, failure_color(
29
+ "\u1F494"
30
+ )
31
+ end
32
+
33
+ # --
34
+ # Pending.
35
+ # --
36
+ def example_pending(_)
37
+ newline_or_addup
38
+ output.print " ".freeze, pending_color(
39
+ "\u2764"
40
+ )
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ RSpec.configure do |config|
47
+ config.formatter = "Luna::Formatters::Hearts"
48
+ end
@@ -0,0 +1,117 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2015 - 2017 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ module Luna
6
+ module Formatters
7
+ module Profiling
8
+ GROUPS = " %{l} \u2910 %{c} for %{t}"
9
+ EXAMPLES_HEADER = "\nTop %{s} slowest examples (%{t}s), %{p}%% of total time:\n"
10
+ GROUPS_HEADER = "\nTop %{s} slowest example groups:"
11
+ EXAMPLES = " %{l} \u2910 %{s}"
12
+
13
+ # --
14
+ # Help.
15
+ # --
16
+ def helpers
17
+ RSpec::Core::Formatters::Helpers
18
+ end
19
+
20
+ # --
21
+ # Profile.
22
+ # --
23
+ def dump_profile(profile)
24
+ dump_profile_slowest_examples(profile)
25
+ dump_profile_slowest_example_groups(
26
+ profile
27
+ )
28
+ end
29
+
30
+ # --
31
+ # Slow examples.
32
+ # --
33
+ private
34
+ def dump_profile_slowest_examples(profile)
35
+ examples_header(profile)
36
+
37
+ profile.slowest_examples.each do |e|
38
+ sec = helpers.format_seconds(e.execution_result.run_time)
39
+ sec = sec + " seconds"
40
+
41
+ @output.puts EXAMPLES % {
42
+ :l => format_caller(e.location),
43
+ :s => sec.to_f < 1 ? success_color(sec) : failure_color(sec),
44
+ :d => e.full_description
45
+ }
46
+ end
47
+ end
48
+
49
+ # --
50
+ # Slowest example groups.
51
+ # --
52
+ private
53
+ def dump_profile_slowest_example_groups(profile)
54
+ groups_header(profile)
55
+
56
+ profile.slowest_groups.each do |l, h|
57
+ sec = helpers.format_seconds(h[:total_time])
58
+ sec = sec + " seconds"
59
+
60
+ @output.puts color_blue(GROUPS % {
61
+ :d => h[:description],
62
+ :t => sec.to_f < 2 ? success_color(sec) : failure_color(sec),
63
+ :l => color_blue(strip_relative(l)),
64
+ :c => h[:count]
65
+ })
66
+ end
67
+ end
68
+
69
+ # --
70
+ # Headers group.
71
+ # --
72
+ private
73
+ def groups_header(profile)
74
+ @output.puts GROUPS_HEADER % {
75
+ :s => profile.slowest_groups.size
76
+ }
77
+ end
78
+
79
+ # --
80
+ # Header example.
81
+ # --
82
+ private
83
+ def examples_header(profile)
84
+ @output.puts EXAMPLES_HEADER % {
85
+ :s => profile.slowest_examples.size,
86
+ :t => helpers.format_seconds(profile.slow_duration),
87
+ :p => profile.percentage
88
+ }
89
+ end
90
+
91
+ # --
92
+ private
93
+ def color_blue(str)
94
+ Object::RSpec::Core::Formatters::ConsoleCodes.wrap(
95
+ str, :cyan
96
+ )
97
+ end
98
+
99
+ # --
100
+ private
101
+ def strip_relative(path)
102
+ path.gsub(
103
+ /\A\.\//, ""
104
+ )
105
+ end
106
+
107
+ # --
108
+ private
109
+ def format_caller(caller_info)
110
+ color_blue strip_relative(::RSpec.configuration.backtrace_formatter.
111
+ backtrace_line(
112
+ caller_info.to_s.split(':in `block').first
113
+ ))
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,48 @@
1
+ # Frozen-string-literal: true
2
+ # Copyright: 2015 - 2017 Jordon Bedwell - MIT License
3
+ # Encoding: utf-8
4
+
5
+ require_relative "emoji"
6
+
7
+ module Luna
8
+ module Formatters
9
+ class Smiles < Emoji
10
+ Formatters.register self, :start, :start_dump, :example_passed,
11
+ :example_pending, :example_failed, :dump_profile
12
+
13
+ # --
14
+ # Passed.
15
+ # --
16
+ def example_passed(_)
17
+ newline_or_addup
18
+ output.print " ".freeze, success_color(
19
+ "\u263A"
20
+ )
21
+ end
22
+
23
+ # --
24
+ # Failed.
25
+ # --
26
+ def example_failed(_)
27
+ newline_or_addup
28
+ output.print " ".freeze, failure_color(
29
+ "\u2639"
30
+ )
31
+ end
32
+
33
+ # --
34
+ # Pending.
35
+ # --
36
+ def example_pending(_)
37
+ newline_or_addup
38
+ output.print " ".freeze, pending_color(
39
+ "\u2639"
40
+ )
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ RSpec.configure do |c|
47
+ c.formatter = "Luna::Formatters::Smilies"
48
+ end
@@ -3,9 +3,7 @@
3
3
  # Encoding: utf-8
4
4
 
5
5
  module Luna
6
- module Rspec
7
- module Formatters
8
- VERSION = "3.8.1"
9
- end
6
+ module Formatters
7
+ VERSION = "3.9.0"
10
8
  end
11
9
  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: 3.8.1
4
+ version: 3.9.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: 2017-10-23 00:00:00.000000000 Z
11
+ date: 2017-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.14'
19
+ version: '3.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '4.0'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '2.14'
29
+ version: '3.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '4.0'
@@ -40,13 +40,14 @@ files:
40
40
  - Gemfile
41
41
  - LICENSE
42
42
  - README.md
43
+ - lib/luna/rspec/formatters.rb
43
44
  - lib/luna/rspec/formatters/cats.rb
44
45
  - lib/luna/rspec/formatters/checks.rb
46
+ - lib/luna/rspec/formatters/documentation.rb
45
47
  - lib/luna/rspec/formatters/emoji.rb
46
- - lib/luna/rspec/formatters/fulldesc.rb
47
- - lib/luna/rspec/formatters/hearts.rb
48
- - lib/luna/rspec/formatters/profile.rb
49
- - lib/luna/rspec/formatters/smilies.rb
48
+ - lib/luna/rspec/formatters/heart.rb
49
+ - lib/luna/rspec/formatters/profiling.rb
50
+ - lib/luna/rspec/formatters/smiles.rb
50
51
  - lib/luna/rspec/formatters/version.rb
51
52
  homepage: https://github.com/envygeeks/luna-rspec-formatters
52
53
  licenses:
@@ -68,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
69
  version: '0'
69
70
  requirements: []
70
71
  rubyforge_project:
71
- rubygems_version: 2.5.2
72
+ rubygems_version: 2.6.13
72
73
  signing_key:
73
74
  specification_version: 4
74
75
  summary: RSpec formatters dedicated to Luna.
@@ -1,103 +0,0 @@
1
- # Frozen-string-literal: true
2
- # Copyright: 2015 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: utf-8
4
-
5
- require "rspec/core/formatters/base_text_formatter"
6
- require "luna/rspec/formatters/profile"
7
- require "rspec/version"
8
- require "coderay"
9
-
10
- module Luna
11
- module RSpec
12
- module Formatters
13
- class Documentation < ::RSpec::Core::Formatters::BaseTextFormatter
14
- include Profile
15
-
16
- if Gem::Version.new(::RSpec::Version::STRING) >= Gem::Version.new("3.0")
17
- then Object::RSpec::Core::Formatters.register self, *[
18
- :start,
19
- :start_dump,
20
- :example_passed,
21
- :example_pending,
22
- :example_failed,
23
- :dump_profile
24
- ]
25
- end
26
-
27
- # --
28
- [:success, :failure, :pending].each do |m|
29
- define_method "#{m}_color" do |v|
30
- defined?(super) ? super(v) : ::RSpec::Core::Formatters::ConsoleCodes.wrap(
31
- v, m
32
- )
33
- end
34
- end
35
-
36
- # --
37
- # Start.
38
- # --
39
- def start(_)
40
- output.puts
41
- end
42
-
43
- # --
44
- # End.
45
- # --
46
- def start_dump(_)
47
- output.puts
48
- end
49
-
50
- # --
51
- # Passed.
52
- # --
53
- def example_passed(struct)
54
- output.print "\s"
55
- print_description(
56
- get_example(struct), :success
57
- )
58
- end
59
-
60
- # --
61
- # Failed.
62
- # --
63
- def example_failed(struct)
64
- output.print "\s"
65
- print_description(
66
- get_example(struct), :failure
67
- )
68
- end
69
-
70
- # --
71
- # Pending.
72
- # --
73
- def example_pending(struct)
74
- output.print "\s"
75
- print_description(
76
- get_example(struct), :pending
77
- )
78
- end
79
-
80
- # --
81
- # Pull.
82
- # --
83
- def get_example(struct)
84
- return struct unless struct.respond_to?(:example)
85
- struct.example
86
- end
87
-
88
- # --
89
- # Description.
90
- # --
91
- def print_description(example, type)
92
- output.print send(
93
- :"#{type}_color", " " + example.full_description + "\n"
94
- )
95
- end
96
- end
97
- end
98
- end
99
- end
100
-
101
- RSpec.configure do |config|
102
- config.formatter = "Luna::RSpec::Formatters::Documentation"
103
- end
@@ -1,58 +0,0 @@
1
- # Frozen-string-literal: true
2
- # Copyright: 2015 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: utf-8
4
-
5
- require "luna/rspec/formatters/emoji"
6
-
7
- module Luna
8
- module RSpec
9
- module Formatters
10
- class Hearts < Emoji
11
- if Gem::Version.new(Object::RSpec::Version::STRING) >= Gem::Version.new("3.0")
12
- then Object::RSpec::Core::Formatters.register self, *[
13
- :start,
14
- :start_dump,
15
- :example_passed,
16
- :example_pending,
17
- :example_failed,
18
- :dump_profile
19
- ]
20
- end
21
-
22
- # --
23
- # Passed.
24
- # --
25
- def example_passed(_)
26
- newline_or_addup
27
- output.print " ".freeze, success_color(
28
- "\u2764"
29
- )
30
- end
31
-
32
- # --
33
- # Failed.
34
- # --
35
- def example_failed(_)
36
- newline_or_addup
37
- output.print " ".freeze, failure_color(
38
- "\u1F494"
39
- )
40
- end
41
-
42
- # --
43
- # Pending.
44
- # --
45
- def example_pending(_)
46
- newline_or_addup
47
- output.print " ".freeze, pending_color(
48
- "\u2764"
49
- )
50
- end
51
- end
52
- end
53
- end
54
- end
55
-
56
- RSpec.configure do |config|
57
- config.formatter = "Luna::RSpec::Formatters::Hearts"
58
- end
@@ -1,119 +0,0 @@
1
- # Frozen-string-literal: true
2
- # Copyright: 2015 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: utf-8
4
-
5
- module Luna
6
- module RSpec
7
- module Formatters
8
- module Profile
9
- GROUPS = " %{location} \u2910 %{count} for %{total}"
10
- EXAMPLES_HEADER = "\nTop %{size} slowest examples (%{seconds}s), %{per_cent}%% of total time:\n"
11
- GROUPS_HEADER = "\nTop %{size} slowest example groups:"
12
- EXAMPLES = " %{location} \u2910 %{seconds}"
13
-
14
- # --
15
- # Help.
16
- # --
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 EXAMPLES % {
44
- :location => format_caller(e.location),
45
- :seconds => sec.to_f < 1 ? success_color(sec) : failure_color(sec),
46
- :description => 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(GROUPS % {
63
- :description => h[:description],
64
- :total => sec.to_f < 2 ? success_color(sec) : failure_color(sec),
65
- :location => 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 GROUPS_HEADER % {
77
- :size => profile.slowest_groups.size
78
- }
79
- end
80
-
81
- # --
82
- # Header example.
83
- # --
84
- private
85
- def examples_header(profile)
86
- @output.puts EXAMPLES_HEADER % {
87
- :size => profile.slowest_examples.size,
88
- :seconds => helpers.format_seconds(profile.slow_duration),
89
- :per_cent => profile.percentage
90
- }
91
- end
92
-
93
- # --
94
- private
95
- def color_blue(str)
96
- Object::RSpec::Core::Formatters::ConsoleCodes.wrap(
97
- str, :cyan
98
- )
99
- end
100
-
101
- # --
102
- private
103
- def strip_relative(path)
104
- path.gsub(
105
- /\A\.\//, ""
106
- )
107
- end
108
-
109
- # --
110
- private
111
- def format_caller(caller_info)
112
- color_blue strip_relative(::RSpec.configuration.backtrace_formatter.backtrace_line(
113
- caller_info.to_s.split(':in `block').first
114
- ))
115
- end
116
- end
117
- end
118
- end
119
- end
@@ -1,58 +0,0 @@
1
- # Frozen-string-literal: true
2
- # Copyright: 2015 - 2017 Jordon Bedwell - MIT License
3
- # Encoding: utf-8
4
-
5
- require "luna/rspec/formatters/emoji"
6
-
7
- module Luna
8
- module RSpec
9
- module Formatters
10
- class Smilies < Emoji
11
- if Gem::Version.new(Object::RSpec::Version::STRING) >= Gem::Version.new("3.0")
12
- then Object::RSpec::Core::Formatters.register self, *[
13
- :start,
14
- :start_dump,
15
- :example_passed,
16
- :example_pending,
17
- :example_failed,
18
- :dump_profile
19
- ]
20
- end
21
-
22
- # --
23
- # Passed.
24
- # --
25
- def example_passed(_)
26
- newline_or_addup
27
- output.print " ".freeze, success_color(
28
- "\u263A"
29
- )
30
- end
31
-
32
- # --
33
- # Failed.
34
- # --
35
- def example_failed(_)
36
- newline_or_addup
37
- output.print " ".freeze, failure_color(
38
- "\u2639"
39
- )
40
- end
41
-
42
- # --
43
- # Pending.
44
- # --
45
- def example_pending(_)
46
- newline_or_addup
47
- output.print " ".freeze, pending_color(
48
- "\u2639"
49
- )
50
- end
51
- end
52
- end
53
- end
54
- end
55
-
56
- RSpec.configure do |config|
57
- config.formatter = "Luna::RSpec::Formatters::Smilies"
58
- end