rspec-github 1.0.0 → 2.3.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
  SHA256:
3
- metadata.gz: 28a3e04c1fd378d28549e10d10894dd8558049d46bf405955bb0715eb445f2d0
4
- data.tar.gz: 489c9027cb9d8a1b79eaf84104736c1c772d99012dc15db5bbbb2d877ecb5d89
3
+ metadata.gz: 809f1c358c9c727c2cb824a727cbf4d012238f30cb5d817274f5d05a719ec253
4
+ data.tar.gz: 6b4771a4936c7cc0cffdd20b69399f75ca658fa7a5d097e8c9bcaafb15257473
5
5
  SHA512:
6
- metadata.gz: 824beadb093bdb64fa899da2375ab31b0ca6f6f5527fa568226fd438b200fbf2b22000c5a4a5cbc2c56646b6013e2e7bd63980cbf0e1ee5229f00623019dc98b
7
- data.tar.gz: d87a85b97475e413a68eb9d99b40154edc5426329d64685e88f2d278cd8b4c200990862562afcd646b83724870f008d76084a2f95a59b8697c673d8743e41434
6
+ metadata.gz: 7cbdaf2dc830b47a275b30f037984212e2fdd791ca042c3d8886a74f69cf10c908fa4c078633261da96cf1c7df95333e4465aa93f9574a4c75066595855041ae
7
+ data.tar.gz: edf61602b543774d83693a3438be2954d175a14a37e8c843af303f33a984ced3bc038dbf82194c7ef615d642f6c44a10756203237276be1162f7c9c77151379d
@@ -3,7 +3,7 @@
3
3
  require 'rspec/github/version'
4
4
  require 'rspec/github/formatter'
5
5
 
6
- module Rspec
6
+ module RSpec
7
7
  module Github
8
8
  end
9
9
  end
@@ -1,22 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rspec/core/formatters/documentation_formatter'
3
+ require 'rspec/core'
4
+ require 'rspec/core/formatters/base_formatter'
5
+ require 'rspec/github/notification_decorator'
4
6
 
5
7
  module RSpec
6
8
  module Github
7
- class Formatter < RSpec::Core::Formatters::DocumentationFormatter
9
+ class Formatter < RSpec::Core::Formatters::BaseFormatter
8
10
  RSpec::Core::Formatters.register self, :example_failed, :example_pending
9
11
 
10
12
  def example_failed(failure)
11
- super
12
- file, line = failure.example.location.split(':')
13
- output.puts "::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}"
14
16
  end
15
17
 
16
18
  def example_pending(pending)
17
- super
18
- file, line = pending.example.location.split(':')
19
- output.puts "::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}"
20
22
  end
21
23
  end
22
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Rspec
3
+ module RSpec
4
4
  module Github
5
- VERSION = '1.0.0'
5
+ VERSION = '2.3.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.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-04-02 00:00:00.000000000 Z
11
+ date: 2020-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -47,6 +61,7 @@ extra_rdoc_files: []
47
61
  files:
48
62
  - lib/rspec/github.rb
49
63
  - lib/rspec/github/formatter.rb
64
+ - lib/rspec/github/notification_decorator.rb
50
65
  - lib/rspec/github/version.rb
51
66
  homepage: https://drieam.github.io/rspec-github
52
67
  licenses: