Sha256: 7b6336bf5ef2bab7e2e70875ca7509e911ae2d43d28c551a502c80137eb88ab3
Contents?: true
Size: 1.81 KB
Versions: 4
Compression:
Stored size: 1.81 KB
Contents
require 'cucumber/formatter/console' module Cucumber module Formatter class Nagios def initialize(step_mother, io, options={}) @failed = [] @passed = [] @warning = [] @io = io @start_time = Time.now end def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) record_result(status, :step_match => step_match) end def before_examples(*args) @header_row = true end def after_table_row(table_row) unless @header_row record_result(table_row.status) if table_row.respond_to?(:status) end @header_row = false if @header_row end def after_features(steps) print_summary end private def print_summary @total = @failed.size + @passed.size + @warning.size @status = @failed.size > 0 && "CRITICAL" || @warning.size > 0 && "WARNING" || "OK" @run_time = (Time.now - @start_time).to_i service_output = [ "CUCUMBER #{@status} - Critical: #{@failed.size}", "Warning: #{@warning.size}", "#{@passed.size} okay" ] performance_data = [ "passed=#{@passed.size}", "failed=#{@failed.size}", "nosteps=#{@warning.size}", "total=#{@total}", "time=#{@run_time}" ] message = "#{service_output.join(', ')} | #{performance_data.join('; ')}\n" @io.print(message) @io.flush end def record_result(status, opts={}) step_match = opts[:step_match] || true case status when :passed @passed << step_match when :failed @failed << step_match when :undefined @warning << step_match end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems