lib/gurke/reporters/team_city_reporter.rb in gurke-2.4.2 vs lib/gurke/reporters/team_city_reporter.rb in gurke-3.0.0

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + module Gurke::Reporters # # The {TeamCityReporter} prints features, scenarios and # steps in a format parseable by TeamCity CI. # @@ -19,13 +21,11 @@ @scenario = scenario publish :testStarted, name: scenario.name end def start_background(*) - unless @background - io.puts ' Background:' - end + io.puts ' Background:' unless @background @background = true end def end_background(*) @@ -75,34 +75,32 @@ def print_braces(str) io.print " (#{str})" end - def print_pending(step) + def print_pending(_step) return if @pending == @scenario # only once per scenario publish :testIgnored, - name: @scenario.name, - message: 'Step definition missing' + name: @scenario.name, + message: 'Step definition missing' @pending = @scenario end def print_failed(step) publish :testFailed, - name: @scenario.name, - message: step.exception.inspect, - backtrace: step.exception.backtrace.join('\n') + name: @scenario.name, + message: step.exception.inspect, + backtrace: step.exception.backtrace.join('\n') @pending = @scenario print_braces 'failure' io.puts exout = format_exception(step.exception) - io.puts exout.map{|s| " #{s}\n" }.join + io.puts exout.map {|s| " #{s}\n" }.join end - - private def publish(message_name, args) args = [] << message_name.to_s << escaped_array_of(args) args = args.flatten.reject(&:nil?) io.puts "##teamcity[#{args.join(' ')}]" @@ -114,10 +112,10 @@ def escaped_array_of(args) return [] if args.nil? if args.is_a? Hash - args.map { |key, value| "#{key.to_s}='#{escape value.to_s}'" } + args.map {|key, value| "#{key}='#{escape value.to_s}'" } else "'#{escape args}'" end end