Class: Cucumber::Formatter::Usage
- Includes:
- Console
- Defined in:
- lib/cucumber/formatter/usage.rb
Direct Known Subclasses
Defined Under Namespace
Classes: StepDefKey
Constant Summary
Constants included from ANSIColor
Constants included from Term::ANSIColor
Term::ANSIColor::ATTRIBUTES, Term::ANSIColor::ATTRIBUTE_NAMES, Term::ANSIColor::COLORED_REGEXP
Instance Attribute Summary
Attributes inherited from Progress
Instance Method Summary collapse
- #after_test_step(test_step, result) ⇒ Object
-
#initialize(runtime, path_or_io, options) ⇒ Usage
constructor
A new instance of Usage.
Methods included from Console
#collect_failing_scenarios, #collect_snippet_data, #embed, #empty_messages, #format_step, #format_string, #linebreaks, #print_elements, #print_exception, #print_failing_scenarios, #print_message, #print_messages, #print_passing_wip, #print_profile_information, #print_snippets, #print_statistics, #print_stats, #print_table_row_messages, #puts
Methods included from ANSIColor
#cukes, define_grey, define_real_grey, #green_cukes, #grey, #red_cukes, #yellow_cukes
Methods included from Term::ANSIColor
attributes, coloring=, coloring?, #uncolored
Methods included from Summary
#scenario_summary, #step_summary
Methods included from Duration
Methods inherited from Progress
#after_test_case, #before_test_case, #done
Methods included from Io
ensure_dir, ensure_file, ensure_io
Constructor Details
#initialize(runtime, path_or_io, options) ⇒ Usage
Returns a new instance of Usage.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cucumber/formatter/usage.rb', line 13 def initialize(runtime, path_or_io, ) @runtime = runtime @io = ensure_io(path_or_io) @options = @stepdef_to_match = Hash.new { |h, stepdef_key| h[stepdef_key] = [] } @total_duration = 0 @matches = {} runtime.configuration.on_event :step_match do |event| @matches[event.test_step.source] = event.step_match end end |
Instance Method Details
#after_test_step(test_step, result) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cucumber/formatter/usage.rb', line 25 def after_test_step(test_step, result) return if HookQueryVisitor.new(test_step).hook? step_match = @matches[test_step.source] step_definition = step_match.step_definition stepdef_key = StepDefKey.new(step_definition.regexp_source, step_definition.location) unless @stepdef_to_match[stepdef_key].map { |key| key[:location] }.include? test_step.location duration = DurationExtractor.new(result).result_duration @stepdef_to_match[stepdef_key] << { keyword: test_step.source.last.keyword, step_match: step_match, status: result.to_sym, location: test_step.location, duration: duration } end super end |