From f14503bb88d453f50d5603699050f53f63770053 Mon Sep 17 00:00:00 2001 From: Nick Abalov Date: Sun, 14 Jan 2018 19:39:18 +0000 Subject: [PATCH] Fix incompatible encodings error in junit formatter --- lib/cucumber/formatter/interceptor.rb | 11 +++++++++-- lib/cucumber/formatter/junit.rb | 4 ++-- spec/cucumber/formatter/interceptor_spec.rb | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/cucumber/formatter/interceptor.rb b/lib/cucumber/formatter/interceptor.rb index 07bb150360..694ca08a75 100644 --- a/lib/cucumber/formatter/interceptor.rb +++ b/lib/cucumber/formatter/interceptor.rb @@ -8,7 +8,7 @@ class Pipe attr_reader :pipe def initialize(pipe) @pipe = pipe - @buffer = [] + @buffer = StringIO.new @wrapped = true end @@ -19,9 +19,16 @@ def write(str) end end + # @deprecated use #buffer_string def buffer lock.synchronize do - return @buffer.dup + return @buffer.string.lines + end + end + + def buffer_string + lock.synchronize do + return @buffer.string.dup end end diff --git a/lib/cucumber/formatter/junit.rb b/lib/cucumber/formatter/junit.rb index 24f30d163a..3daacf6172 100644 --- a/lib/cucumber/formatter/junit.rb +++ b/lib/cucumber/formatter/junit.rb @@ -140,10 +140,10 @@ def build_testcase(result, scenario_designation, output) @current_feature_data[:failures] += 1 end @current_feature_data[:builder].tag!('system-out') do - @current_feature_data[:builder].cdata! strip_control_chars(@interceptedout.buffer.join) + @current_feature_data[:builder].cdata! strip_control_chars(@interceptedout.buffer_string) end @current_feature_data[:builder].tag!('system-err') do - @current_feature_data[:builder].cdata! strip_control_chars(@interceptederr.buffer.join) + @current_feature_data[:builder].cdata! strip_control_chars(@interceptederr.buffer_string) end end @current_feature_data[:tests] += 1 diff --git a/spec/cucumber/formatter/interceptor_spec.rb b/spec/cucumber/formatter/interceptor_spec.rb index 006534534e..1202327237 100644 --- a/spec/cucumber/formatter/interceptor_spec.rb +++ b/spec/cucumber/formatter/interceptor_spec.rb @@ -114,6 +114,7 @@ module Cucumber::Formatter expect(pi.buffer).not_to be_empty expect(pi.buffer.first).to eq buffer + expect(pi.buffer_string).to eq buffer end end