-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4ba7b77
commit e1e763f
Showing
9 changed files
with
151 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
require 'fuubar' | ||
|
||
module Flatware | ||
module RSpec | ||
module Formatters | ||
class Fuubar | ||
attr_reader :progress_formatter, :out, :deprecation_stream | ||
|
||
def initialize(out, deprecation_stream: StringIO.new) | ||
@out = out | ||
@deprecation_stream = deprecation_stream | ||
::RSpec.configuration.backtrace_exclusion_patterns += [%r{/lib/flatware/worker}, %r{/lib/flatware/rspec}] | ||
@progress_formatter = ::Fuubar.new(out) | ||
end | ||
|
||
def worker_ready(notification) | ||
if progress_formatter.progress.total > 0 | ||
progress_formatter.progress.total += notification.count | ||
else | ||
progress_formatter.start(notification) | ||
end | ||
end | ||
|
||
def progress(result) | ||
progress_formatter.public_send(message_for(result), result) | ||
end | ||
|
||
def message(message) | ||
out.puts(message.message) | ||
end | ||
|
||
def summarize(checkpoints) | ||
return if checkpoints.empty? | ||
|
||
result = checkpoints.reduce :+ | ||
|
||
progress_formatter.dump_pending(result) if result.pending_examples.any? | ||
progress_formatter.dump_failures(result) | ||
dump_deprecations(result.deprecations) | ||
dump_profile(result.profile) if result.profile | ||
progress_formatter.dump_summary(result.summary) | ||
end | ||
|
||
def summarize_remaining(remaining) | ||
out.puts(colorizer.wrap(<<~MESSAGE, :detail)) | ||
The following specs weren't run: | ||
#{spec_list(remaining)} | ||
MESSAGE | ||
end | ||
|
||
private | ||
|
||
def dump_deprecations(deprecations) | ||
formatter = ::RSpec::Core::Formatters::DeprecationFormatter.new( | ||
deprecation_stream, | ||
out | ||
) | ||
|
||
deprecations.each(&formatter.method(:deprecation)) | ||
formatter.deprecation_summary(nil) | ||
end | ||
|
||
def dump_profile(profile) | ||
::RSpec::Core::Formatters::ProfileFormatter.new(out).dump_profile(profile) | ||
end | ||
|
||
def spec_list(remaining) | ||
remaining | ||
.flat_map(&:id).sort.each_with_index | ||
.map do |example, index| | ||
format( | ||
'%<index>4d) %<example>s', | ||
index: index.next, | ||
example: example | ||
) | ||
end.join("\n") | ||
end | ||
|
||
def colorizer | ||
::RSpec::Core::Formatters::ConsoleCodes | ||
end | ||
|
||
def message_for(notification) | ||
{ | ||
passed: :example_passed, | ||
failed: :example_failed, | ||
pending: :example_pending | ||
}.fetch notification.example.execution_result.status | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'rspec/core' | ||
require 'flatware/rspec/marshalable/example' | ||
|
||
module Flatware | ||
module RSpec | ||
module Marshalable | ||
class ExampleNotification < ::RSpec::Core::Notifications::ExampleNotification | ||
def self.from_rspec(rspec_notification) | ||
new(Example.new(rspec_notification.example)) | ||
end | ||
|
||
def fully_formatted(failure_number, colorizer=::RSpec::Core::Formatters::ConsoleCodes) | ||
return if example.execution_result.status != :failed | ||
|
||
@exception_presenter ||= ::RSpec::Core::Formatters::ExceptionPresenter::Factory.new(example).build | ||
@exception_presenter.fully_formatted(failure_number, colorizer) | ||
end | ||
end | ||
end | ||
end | ||
end |