rspec-ci-prettify 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspec/ci/prettify/annotation.rb +54 -0
- data/lib/rspec/ci/prettify/formatter.rb +11 -10
- data/lib/rspec/ci/prettify/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4814566aeb1130a8ca2d63035a0664b8120753d608c280270f3e2369141033d
|
4
|
+
data.tar.gz: f2ee21c3127d7e5fc789994ee2efc75baafc0848ee81fda995f57c57e0ce96f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe45b373da2386e1a681535cb062c7d93637e6dd03708c76fd678349046a3e1228ff14af78aad34999387821b1d07c6a65534d7ea7b26778c0a88dfe14ae2028
|
7
|
+
data.tar.gz: 776c156d70fa5bcd18342c165bcb6698b45c4e2f8fba2e3aec66299eecc0dbcd08896d7b7f050330720d95122a57f173875b1c4106be660acd4eb53514102a48
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module RSpec
|
3
|
+
module Ci
|
4
|
+
module Prettify
|
5
|
+
class Annotation
|
6
|
+
def initialize(notification)
|
7
|
+
@notification = notification
|
8
|
+
@example = notification.example
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :example, :notification
|
12
|
+
|
13
|
+
def line
|
14
|
+
location.split(':')[1]
|
15
|
+
end
|
16
|
+
|
17
|
+
def error
|
18
|
+
msg = notification.message_lines.join("\n")
|
19
|
+
format_annotation_err(msg)
|
20
|
+
end
|
21
|
+
|
22
|
+
def file
|
23
|
+
File.realpath(location.split(':')[0]).sub(/\A#{github_workspace_file_path}#{File::SEPARATOR}/, '')
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def format_annotation_err(str)
|
29
|
+
stripped_str = strip_ansi_colours(str)
|
30
|
+
formatted_str = stripped_str.gsub("\n", '').gsub('"', "'")
|
31
|
+
formatted_str.squeeze(" ")
|
32
|
+
end
|
33
|
+
|
34
|
+
# running --force-color for rspec for a more readable CI
|
35
|
+
# output works great but unfortunately ANSI colours dont
|
36
|
+
# get parsed properly on github annotations therefore
|
37
|
+
# make them harder to read. Stripping any ANSI colours
|
38
|
+
# on annotations here gives us the best of both worlds
|
39
|
+
# readable annotations and readable coloured CI
|
40
|
+
def strip_ansi_colours(str)
|
41
|
+
str.gsub(/\e\[(\d+)(;\d+)*m/, '')
|
42
|
+
end
|
43
|
+
|
44
|
+
def github_workspace_file_path
|
45
|
+
File.realpath(ENV.fetch('GITHUB_WORKSPACE', '.'))
|
46
|
+
end
|
47
|
+
|
48
|
+
def location
|
49
|
+
example.location
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -4,6 +4,7 @@ require 'rspec/core'
|
|
4
4
|
require 'rspec/core/formatters/base_formatter'
|
5
5
|
require 'rspec/core/formatters/console_codes'
|
6
6
|
require_relative 'constants'
|
7
|
+
require_relative 'annotation'
|
7
8
|
|
8
9
|
module RSpec
|
9
10
|
module Ci
|
@@ -20,7 +21,7 @@ module RSpec
|
|
20
21
|
@output << "\n\n"
|
21
22
|
@output << RSpec::Core::Formatters::ConsoleCodes.wrap(RSpec::Ci::Prettify::Constants::SEPARATOR, :bold_white)
|
22
23
|
@output << "\n\n"
|
23
|
-
@output << RSpec::Core::Formatters::ConsoleCodes.wrap(
|
24
|
+
@output << RSpec::Core::Formatters::ConsoleCodes.wrap('SUMMARY:', :cyan)
|
24
25
|
|
25
26
|
build_summary(summary)
|
26
27
|
end
|
@@ -29,7 +30,7 @@ module RSpec
|
|
29
30
|
@output << "\n\n"
|
30
31
|
@output << RSpec::Core::Formatters::ConsoleCodes.wrap(RSpec::Ci::Prettify::Constants::SEPARATOR, :bold_white)
|
31
32
|
@output << "\n\n"
|
32
|
-
@output << RSpec::Core::Formatters::ConsoleCodes.wrap(
|
33
|
+
@output << RSpec::Core::Formatters::ConsoleCodes.wrap('PENDING:', :pending)
|
33
34
|
@output << "\n\n\t"
|
34
35
|
|
35
36
|
@output << notification.pending_examples.map do |example|
|
@@ -41,20 +42,19 @@ module RSpec
|
|
41
42
|
@output << "\n\n"
|
42
43
|
@output << RSpec::Core::Formatters::ConsoleCodes.wrap(RSpec::Ci::Prettify::Constants::SEPARATOR, :bold_white)
|
43
44
|
@output << "\n\n"
|
44
|
-
@output << RSpec::Core::Formatters::ConsoleCodes.wrap(
|
45
|
+
@output << RSpec::Core::Formatters::ConsoleCodes.wrap('FAILURES:', :failure)
|
45
46
|
@output << "\n\n\t"
|
46
47
|
@output << failed_examples_output(notification)
|
47
48
|
end
|
48
49
|
|
49
|
-
def
|
50
|
-
|
50
|
+
def example_failed(notification)
|
51
|
+
annotation = RSpec::Ci::Prettify::Annotation.new(notification)
|
52
|
+
output << "\n::error file=#{annotation.file},line=#{annotation.line}::#{annotation.error}"
|
51
53
|
end
|
52
54
|
|
53
|
-
def
|
54
|
-
end
|
55
|
+
def example_passed(_example); end
|
55
56
|
|
56
|
-
def example_pending(
|
57
|
-
end
|
57
|
+
def example_pending(_example); end
|
58
58
|
|
59
59
|
def close(_notification)
|
60
60
|
@output << "\n"
|
@@ -76,7 +76,8 @@ module RSpec
|
|
76
76
|
|
77
77
|
if pass_count == total_tests_ran
|
78
78
|
@output << "\n"
|
79
|
-
@output << RSpec::Core::Formatters::ConsoleCodes.wrap("All #{total_tests_ran} tests ran passed!!!",
|
79
|
+
@output << RSpec::Core::Formatters::ConsoleCodes.wrap("All #{total_tests_ran} tests ran passed!!!",
|
80
|
+
:magenta)
|
80
81
|
return
|
81
82
|
end
|
82
83
|
@output << "\n"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-ci-prettify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jjholmes927
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|
@@ -60,6 +60,7 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- lib/rspec/ci/prettify.rb
|
63
|
+
- lib/rspec/ci/prettify/annotation.rb
|
63
64
|
- lib/rspec/ci/prettify/constants.rb
|
64
65
|
- lib/rspec/ci/prettify/formatter.rb
|
65
66
|
- lib/rspec/ci/prettify/version.rb
|