Class: Specjour::Cucumber::DistributedFormatter
- Inherits:
-
Cucumber::Formatter::Progress
- Object
- Cucumber::Formatter::Progress
- Specjour::Cucumber::DistributedFormatter
- Defined in:
- lib/specjour/cucumber/distributed_formatter.rb
Constant Summary collapse
- OUTCOMES =
[:failed, :skipped, :undefined, :pending, :passed]
Class Attribute Summary collapse
-
.batch_size ⇒ Object
Returns the value of attribute batch_size.
Instance Method Summary collapse
- #after_features(features) ⇒ Object
-
#initialize(step_mother, io, options) ⇒ DistributedFormatter
constructor
A new instance of DistributedFormatter.
- #prepare_elements(elements, status, kind) ⇒ Object
- #prepare_failures ⇒ Object
- #prepare_steps(type) ⇒ Object
- #print_exception(e, status, indent) ⇒ Object
- #print_summary ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(step_mother, io, options) ⇒ DistributedFormatter
Returns a new instance of DistributedFormatter.
8 9 10 11 12 13 14 |
# File 'lib/specjour/cucumber/distributed_formatter.rb', line 8 def initialize(step_mother, io, ) @step_mother = step_mother @io = io @options = @failing_scenarios = [] @step_summary = [] end |
Class Attribute Details
.batch_size ⇒ Object
Returns the value of attribute batch_size.
4 5 6 |
# File 'lib/specjour/cucumber/distributed_formatter.rb', line 4 def batch_size @batch_size end |
Instance Method Details
#after_features(features) ⇒ Object
16 17 18 19 20 |
# File 'lib/specjour/cucumber/distributed_formatter.rb', line 16 def after_features(features) print_summary step_mother.scenarios.clear step_mother.steps.clear end |
#prepare_elements(elements, status, kind) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/specjour/cucumber/distributed_formatter.rb', line 35 def prepare_elements(elements, status, kind) output = '' if elements.any? output += format_string("\n(::) #{status} #{kind} (::)\n", status) output += "\n" end elements.each_with_index do |element, i| if status == :failed output += print_exception(element.exception, status, 0) else output += format_string(element.backtrace_line, status) output += "\n" end @step_summary << output unless output.blank? end end |
#prepare_failures ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/specjour/cucumber/distributed_formatter.rb', line 22 def prepare_failures @failures = step_mother.scenarios(:failed).select { |s| s.is_a?(Cucumber::Ast::Scenario) } if !@failures.empty? @failures.each do |failure| = '' += format_string("cucumber " + failure.file_colon_line, :failed) + += format_string(" # Scenario: " + failure.name, :comment) @failing_scenarios << end end end |
#prepare_steps(type) ⇒ Object
53 54 55 |
# File 'lib/specjour/cucumber/distributed_formatter.rb', line 53 def prepare_steps(type) prepare_elements(step_mother.scenarios(type), type, 'steps') end |
#print_exception(e, status, indent) ⇒ Object
57 58 59 |
# File 'lib/specjour/cucumber/distributed_formatter.rb', line 57 def print_exception(e, status, indent) format_string("#{e.} (#{e.class})\n#{e.backtrace.join("\n")}".indent(indent), status) end |
#print_summary ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/specjour/cucumber/distributed_formatter.rb', line 61 def print_summary prepare_failures prepare_steps(:failed) prepare_steps(:undefined) @io.(:worker_summary=, to_hash) end |
#to_hash ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/specjour/cucumber/distributed_formatter.rb', line 71 def to_hash hash = {} [:scenarios, :steps].each do |type| hash[type] = {} OUTCOMES.each do |outcome| hash[type][outcome] = step_mother.send(type, outcome).size end end hash.merge!(:failing_scenarios => @failing_scenarios, :step_summary => @step_summary) hash end |