rspec-github 2.2.0 → 2.3.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
  SHA256:
3
- metadata.gz: dd0d5193cff4ec8793a8d1a69b3323db05399cb1147d021c51843706beec1cc0
4
- data.tar.gz: 6be59b0609fdbb16663466df65dae210a16d864d2d14f09158ad7d34884fcefe
3
+ metadata.gz: 809f1c358c9c727c2cb824a727cbf4d012238f30cb5d817274f5d05a719ec253
4
+ data.tar.gz: 6b4771a4936c7cc0cffdd20b69399f75ca658fa7a5d097e8c9bcaafb15257473
5
5
  SHA512:
6
- metadata.gz: 5020e2b3b781740bec68cf841d327251615cdc0b572bdfbb6c0200322d0f975c49797cb270d2602fcdb3a3a1b79e7c67b42999a3b838d76a85a5dd013377781f
7
- data.tar.gz: a22208bc4c984718be816a9cdc744912bc282acf8d36239f08c411e8a969f551e7ccc05c549e20d7717019b1e01a3885c8ed194b837957dbc9d8f96d4f5a100b
6
+ metadata.gz: 7cbdaf2dc830b47a275b30f037984212e2fdd791ca042c3d8886a74f69cf10c908fa4c078633261da96cf1c7df95333e4465aa93f9574a4c75066595855041ae
7
+ data.tar.gz: edf61602b543774d83693a3438be2954d175a14a37e8c843af303f33a984ced3bc038dbf82194c7ef615d642f6c44a10756203237276be1162f7c9c77151379d
@@ -2,27 +2,23 @@
2
2
 
3
3
  require 'rspec/core'
4
4
  require 'rspec/core/formatters/base_formatter'
5
+ require 'rspec/github/notification_decorator'
5
6
 
6
7
  module RSpec
7
8
  module Github
8
9
  class Formatter < RSpec::Core::Formatters::BaseFormatter
9
10
  RSpec::Core::Formatters.register self, :example_failed, :example_pending
10
11
 
11
- def self.relative_path(path)
12
- workspace = File.realpath(ENV.fetch('GITHUB_WORKSPACE', '.'))
13
- File.realpath(path).delete_prefix("#{workspace}#{File::SEPARATOR}")
14
- end
15
-
16
12
  def example_failed(failure)
17
- file, line = failure.example.location.split(':')
18
- file = self.class.relative_path(file)
19
- output.puts "\n::error file=#{file},line=#{line}::#{failure.message_lines.join('%0A')}"
13
+ notification = NotificationDecorator.new(failure)
14
+
15
+ output.puts "\n::error file=#{notification.path},line=#{notification.line}::#{notification.annotation}"
20
16
  end
21
17
 
22
18
  def example_pending(pending)
23
- file, line = pending.example.location.split(':')
24
- file = self.class.relative_path(file)
25
- output.puts "\n::warning file=#{file},line=#{line}::#{pending.example.full_description}"
19
+ notification = NotificationDecorator.new(pending)
20
+
21
+ output.puts "\n::warning file=#{notification.path},line=#{notification.line}::#{notification.annotation}"
26
22
  end
27
23
  end
28
24
  end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec
4
+ module Github
5
+ class NotificationDecorator
6
+ # See https://github.community/t/set-output-truncates-multiline-strings/16852/3.
7
+ ESCAPE_MAP = {
8
+ '%' => '%25',
9
+ "\n" => '%0A',
10
+ "\r" => '%0D'
11
+ }.freeze
12
+
13
+ def initialize(notification)
14
+ @notification = notification
15
+ end
16
+
17
+ def line
18
+ example.location.split(':')[1]
19
+ end
20
+
21
+ def annotation
22
+ "#{example.full_description}\n\n#{message}"
23
+ .gsub(Regexp.union(ESCAPE_MAP.keys), ESCAPE_MAP)
24
+ end
25
+
26
+ def path
27
+ File.realpath(raw_path).delete_prefix("#{workspace}#{File::SEPARATOR}")
28
+ end
29
+
30
+ private
31
+
32
+ def example
33
+ @notification.example
34
+ end
35
+
36
+ def message
37
+ if @notification.respond_to?(:message_lines)
38
+ @notification.message_lines.join("\n")
39
+ else
40
+ "#{example.skip ? 'Skipped' : 'Pending'}: #{example.execution_result.pending_message}"
41
+ end
42
+ end
43
+
44
+ def raw_path
45
+ example.location.split(':')[0]
46
+ end
47
+
48
+ def workspace
49
+ File.realpath(ENV.fetch('GITHUB_WORKSPACE', '.'))
50
+ end
51
+ end
52
+ end
53
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Github
5
- VERSION = '2.2.0'
5
+ VERSION = '2.3.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stef Schenkelaars
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-10 00:00:00.000000000 Z
11
+ date: 2020-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core
@@ -61,6 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - lib/rspec/github.rb
63
63
  - lib/rspec/github/formatter.rb
64
+ - lib/rspec/github/notification_decorator.rb
64
65
  - lib/rspec/github/version.rb
65
66
  homepage: https://drieam.github.io/rspec-github
66
67
  licenses: