class Cucumber::Formatter::ConsoleIssues
Public Class Methods
Source
# File lib/cucumber/formatter/console_issues.rb, line 10 def initialize(config, ast_lookup = AstLookup.new(config)) @previous_test_case = nil @issues = Hash.new { |h, k| h[k] = [] } @global_hooks_summary = GlobalHooksSummary.new(config) @config = config @config.on_event(:test_case_finished) do |event| if event.test_case != @previous_test_case @previous_test_case = event.test_case @issues[event.result.to_sym] << event.test_case unless event.result.ok?(@config.strict) elsif event.result.passed? @issues[:flaky] << event.test_case unless Core::Test::Result::Flaky.ok?(@config.strict.strict?(:flaky)) @issues[:failed].delete(event.test_case) end end @ast_lookup = ast_lookup end
Public Instance Methods
Source
# File lib/cucumber/formatter/console_issues.rb, line 33 def any? @issues.any? || !@global_hooks_summary.ok? end
Source
# File lib/cucumber/formatter/console_issues.rb, line 27 def to_s test_case_result = @issues.empty? ? [] : Core::Test::Result::TYPES.map { |type| scenario_listing(type, @issues[type]) } global_hooks_result = @global_hooks_summary.ok? ? [] : @global_hooks_summary.exception_listing [test_case_result + global_hooks_result].flatten.join("\n") end
Private Instance Methods
Source
# File lib/cucumber/formatter/console_issues.rb, line 59 def profiles_string return if @config.custom_profiles.empty? profiles = @config.custom_profiles.map { |profile| "-p #{profile}" }.join(' ') "#{profiles} " end
Source
# File lib/cucumber/formatter/console_issues.rb, line 39 def scenario_listing(type, test_cases) return [] if test_cases.empty? [format_string("#{type_heading(type)} Scenarios:", type)] + test_cases.map do |test_case| scenario_source = @ast_lookup.scenario_source(test_case) keyword = scenario_source.type == :Scenario ? scenario_source.scenario.keyword : scenario_source.scenario_outline.keyword source = @config.source? ? format_string(" # #{keyword}: #{test_case.name}", :comment) : '' format_string("cucumber #{profiles_string}#{test_case.location.file}:#{test_case.location.lines.max}", type) + source end end
Source
# File lib/cucumber/formatter/console_issues.rb, line 50 def type_heading(type) case type when :failed 'Failing' else type.to_s.slice(0, 1).capitalize + type.to_s.slice(1..-1) end end