-
-
Notifications
You must be signed in to change notification settings - Fork 753
Add a minimalist formatter (c/quickfix style output) #2614
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
RSpec::Support.require_rspec_core "formatters/base_formatter" | ||
|
||
module RSpec | ||
module Core | ||
module Formatters | ||
# @private | ||
class MinimalFormatter < BaseFormatter | ||
Formatters.register self, :example_failed, :dump_profile, :message | ||
|
||
def example_failed(failure) | ||
output.puts "#{failure.example.location}:#{failure.example.description}" | ||
end | ||
|
||
# Discard profile and messages | ||
# | ||
# These outputs are not really relevant in the context of this minimal | ||
# formatter. | ||
def dump_profile(_profile); end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so if you want to silence output, can we get a comment here explaining that? Also what about the other output? start / end etc? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I initially chose to discard the profile output because it produce a big chunk of information which is not really useful in the context of an editor (and since the formatter was renamed "minimal" it may make even more sense to discard any "extra" output), but I do not have strong opinion about this, and if you prefer to keep these messages I can amend my work accordingly. I found out that Thanks! |
||
def message(_message); end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'rspec/core/formatters/minimal_formatter' | ||
|
||
module RSpec::Core::Formatters | ||
RSpec.describe MinimalFormatter do | ||
include FormatterSupport | ||
|
||
it 'produces the expected full output' do | ||
output = run_example_specs_with_formatter('minimal') | ||
expect(output).to eq(<<-EOS.gsub(/^\s+\|/, '')) | ||
|./spec/rspec/core/resources/formatter_specs.rb:4:is marked as pending but passes | ||
|./spec/rspec/core/resources/formatter_specs.rb:36:fails | ||
|./spec/rspec/core/resources/formatter_specs.rb:40:fails twice | ||
|./spec/rspec/core/resources/formatter_specs.rb:47:fails with a backtrace that has no file | ||
|./spec/rspec/core/resources/formatter_specs.rb:53:fails with a backtrace containing an erb file | ||
|./spec/rspec/core/resources/formatter_specs.rb:71:raises | ||
EOS | ||
end | ||
end | ||
end |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Minimal" is a subjective term -- I can imagine many different minimal formatters that output different things. Here it seems like this formatter is focused on printing a list of failures. WDYT about calling this
FailureListFormatter
? Seems like a more accurate name.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe, naming things is hard…
The formatter was initially called CFormatter — which was probably an even poorer choice — because it's output look like what a compiler produce…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to change the name,
FailureListFormatter
seems appropriate.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #2624