Class: Cucumber::Formatter::GlobalHooksSummary

Inherits:
Object
  • Object
show all
Includes:
Console
Defined in:
lib/cucumber/formatter/global_hooks_summary.rb

Overview

AllHookSummary formatter, keep track of failures in Before/AfterAll hooks

Constant Summary

Constants included from ANSIColor

ANSIColor::ALIASES

Constants included from Term::ANSIColor

Term::ANSIColor::ATTRIBUTES, Term::ANSIColor::ATTRIBUTE_NAMES, Term::ANSIColor::COLORED_REGEXP

Instance Method Summary collapse

Methods included from Console

#attach, #collect_snippet_data, #collect_undefined_parameter_type_names, #do_print_passing_wip, #do_print_profile_information, #do_print_snippets, #do_print_undefined_parameter_type_snippet, #exception_message_string, #format_step, #format_string, #indent, #linebreaks, #print_element_messages, #print_elements, #print_exception, #print_passing_wip, #print_profile_information, #print_snippets, #print_statistics

Methods included from ANSIColor

apply_custom_colors, #cukes, #green_cukes, #red_cukes, #yellow_cukes

Methods included from Term::ANSIColor

#attributes, included, #uncolored

Methods included from Duration

#format_duration

Constructor Details

#initialize(config) ⇒ GlobalHooksSummary

Returns a new instance of GlobalHooksSummary.



16
17
18
19
20
21
22
23
# File 'lib/cucumber/formatter/global_hooks_summary.rb', line 16

def initialize(config)
  @config = config
  @all_hook_failures = []

  @config.on_event :test_run_hook_finished do |event|
    @all_hook_failures << event unless event.test_result.ok?
  end
end

Instance Method Details

#exception_listingObject



29
30
31
32
33
# File 'lib/cucumber/formatter/global_hooks_summary.rb', line 29

def exception_listing
  [format_string('Global hook failures:', :failed)] + @all_hook_failures.map do |event|
    format_string("#{event.hook.location} # #{event.test_result.exception} (#{event.test_result.exception.class})", :failed)
  end
end

#ok?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/cucumber/formatter/global_hooks_summary.rb', line 25

def ok?
  @all_hook_failures.empty?
end