Skip to content

Commit d9773c2

Browse files
Inherit from Base formatter instead of Documentation
1 parent 116f170 commit d9773c2

File tree

8 files changed

+19
-32
lines changed

8 files changed

+19
-32
lines changed

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
--color
22
--require spec_helper
3+
--format documentation
34
--format RSpec::Github::Formatter

Gemfile.lock

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,20 @@ PATH
22
remote: .
33
specs:
44
rspec-github (1.0.0.develop)
5+
rspec-core (~> 3.0)
56

67
GEM
78
remote: https://rubygems.org/
89
specs:
910
ast (2.4.0)
10-
diff-lcs (1.3)
1111
jaro_winkler (1.5.4)
1212
parallel (1.19.1)
1313
parser (2.7.0.5)
1414
ast (~> 2.4.0)
1515
rainbow (3.0.0)
1616
rexml (3.2.4)
17-
rspec (3.9.0)
18-
rspec-core (~> 3.9.0)
19-
rspec-expectations (~> 3.9.0)
20-
rspec-mocks (~> 3.9.0)
2117
rspec-core (3.9.0)
2218
rspec-support (~> 3.9.0)
23-
rspec-expectations (3.9.0)
24-
diff-lcs (>= 1.2.0, < 2.0)
25-
rspec-support (~> 3.9.0)
26-
rspec-mocks (3.9.0)
27-
diff-lcs (>= 1.2.0, < 2.0)
28-
rspec-support (~> 3.9.0)
2919
rspec-support (3.9.0)
3020
rubocop (0.81.0)
3121
jaro_winkler (~> 1.5.1)
@@ -42,7 +32,6 @@ PLATFORMS
4232
ruby
4333

4434
DEPENDENCIES
45-
rspec (~> 3.0)
4635
rspec-github!
4736
rubocop (~> 0.81.0)
4837

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ And to always run it with this formatter, you can set it in the `.rspec` file:
3232
--format RSpec::Github::Formatter
3333
```
3434

35+
Note that you can select multiple formatters so that you can also see other output:
36+
```bash
37+
rspec --format RSpec::Github::Formatter --format progress
38+
rspec --format RSpec::Github::Formatter --format documentation
39+
```
40+
3541
## Development
3642
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests.
3743
Publishing a new version is handled by the [publish workflow](.github/workflows/publish.yml). This workflow publishes a GitHub release to [rubygems](https://rubygems.org/) with the version defined in the release.

lib/rspec/github.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require 'rspec/github/version'
44
require 'rspec/github/formatter'
55

6-
module Rspec
6+
module RSpec
77
module Github
88
end
99
end

lib/rspec/github/formatter.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
# frozen_string_literal: true
22

3-
require 'rspec/core/formatters/documentation_formatter'
3+
require 'rspec/core'
4+
require 'rspec/core/formatters/base_formatter'
45

56
module RSpec
67
module Github
7-
class Formatter < RSpec::Core::Formatters::DocumentationFormatter
8+
class Formatter < RSpec::Core::Formatters::BaseFormatter
89
RSpec::Core::Formatters.register self, :example_failed, :example_pending
910

1011
def example_failed(failure)
11-
super
1212
file, line = failure.example.location.split(':')
1313
output.puts "::error file=#{file},line=#{line}::#{failure.message_lines.join('%0A')}"
1414
end
1515

1616
def example_pending(pending)
17-
super
1817
file, line = pending.example.location.split(':')
1918
output.puts "::warning file=#{file},line=#{line}::#{pending.example.full_description}"
2019
end

lib/rspec/github/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
module Rspec
3+
module RSpec
44
module Github
55
VERSION = '1.0.0.develop'
66
end

rspec-github.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ require_relative 'lib/rspec/github/version'
44

55
Gem::Specification.new do |spec|
66
spec.name = 'rspec-github'
7-
spec.version = Rspec::Github::VERSION
7+
spec.version = RSpec::Github::VERSION
88
spec.authors = ['Stef Schenkelaars']
99
spec.email = ['stef.schenkelaars@gmail.com']
1010

@@ -21,6 +21,6 @@ Gem::Specification.new do |spec|
2121
# Specify which files should be added to the gem when it is released.
2222
spec.files = Dir['{lib}/**/*']
2323

24-
spec.add_development_dependency 'rspec', '~> 3.0'
24+
spec.add_runtime_dependency 'rspec-core', '~> 3.0'
2525
spec.add_development_dependency 'rubocop', '~> 0.81.0'
2626
end

spec/rspec/github/formatter_spec.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,8 @@
4040
)
4141
end
4242

43-
it 'still includes the documentation format' do
44-
is_expected.to include "#{example.description} (FAILED"
45-
end
46-
47-
it 'includes the GitHub annotation formatted error' do
48-
is_expected.to include <<~MESSAGE
43+
it 'outputs the GitHub annotation formatted error' do
44+
is_expected.to eq <<~MESSAGE
4945
::error file=./spec/models/user_spec.rb,line=12::#{notification.message_lines.join('%0A')}
5046
MESSAGE
5147
end
@@ -61,12 +57,8 @@
6157
)
6258
end
6359

64-
it 'still includes the documentation format' do
65-
is_expected.to include "#{example.description} (PENDING: Not yet implemented)"
66-
end
67-
68-
it 'includes the GitHub annotation formatted error' do
69-
is_expected.to include <<~MESSAGE
60+
it 'outputs the GitHub annotation formatted error' do
61+
is_expected.to eq <<~MESSAGE
7062
::warning file=./spec/models/user_spec.rb,line=12::#{example.full_description}
7163
MESSAGE
7264
end

0 commit comments

Comments
 (0)