Skip to content

Commit

Permalink
Fix incompatible encodings error in junit formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAb committed Jan 14, 2018
1 parent f736058 commit f14503b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions lib/cucumber/formatter/interceptor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Pipe
attr_reader :pipe
def initialize(pipe)
@pipe = pipe
@buffer = []
@buffer = StringIO.new
@wrapped = true
end

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/formatter/junit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/cucumber/formatter/interceptor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f14503b

Please sign in to comment.