-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AO3-4730 - Add Cucumber output formatter (#2647)
- Loading branch information
1 parent
5e6ea9e
commit 92082ed
Showing
3 changed files
with
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module ElapsedTime | ||
def print_elapsed_time(io, start_time) | ||
elapsed_time = (((Time.now - start_time) * 100).to_i / 100.0) | ||
io.print " (#{elapsed_time}s)" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Adapted from https://github.com/tpope/fivemat | ||
require 'cucumber/formatter/progress' | ||
module Ao3Cucumber | ||
class Formatter < ::Cucumber::Formatter::Progress | ||
include ElapsedTime | ||
|
||
def label(feature) | ||
feature.short_name | ||
end | ||
|
||
def before_feature(feature) | ||
@io.print "#{label(feature)}\n" | ||
@io.flush | ||
@exceptions = [] | ||
@start_time = Time.now | ||
end | ||
|
||
def after_feature(_) | ||
print_elapsed_time @io, @start_time | ||
@io.puts | ||
|
||
@exceptions.each do |(exception, status)| | ||
print_exception(exception, status, 2) | ||
end | ||
end | ||
|
||
def exception(exception, status) | ||
@exceptions << [exception, status] | ||
end | ||
|
||
def after_features(_) | ||
@io.puts | ||
print_snippets(@options) | ||
print_passing_wip(@options) | ||
end | ||
end | ||
end |