diff --git a/spec/cucumber/formatter/junit_spec.rb b/spec/cucumber/formatter/junit_spec.rb index ff6b15338e..83c8700fda 100644 --- a/spec/cucumber/formatter/junit_spec.rb +++ b/spec/cucumber/formatter/junit_spec.rb @@ -61,6 +61,38 @@ def after_step(step) it { expect(@doc.xpath('//testsuite/testcase/system-out').first.content).to match(/\s+boo boo\s+/) } end + describe 'is able to handle multiple encodings in pipe' do + before(:each) do + run_defined_feature + @doc = Nokogiri.XML(@formatter.written_files.values.first) + end + define_feature " + Feature: One passing scenario, one failing scenario + + Scenario: Passing + Given a passing ctrl scenario + " + class Junit + def before_step(step) + return unless step.text.match('a passing ctrl scenario') + Interceptor::Pipe.unwrap! :stdout + @fake_io = $stdout = StringIO.new + $stdout.sync = true + @interceptedout = Interceptor::Pipe.wrap(:stdout) + end + + def after_step(step) + return unless step.text.match('a passing ctrl scenario') + @interceptedout.write("encoding ") + @interceptedout.write("pickle".encode("UTF-16")) + $stdout = STDOUT + @fake_io.close + end + end + + it { expect(@doc.xpath('//testsuite/testcase/system-out').first.content).to match(/\s+encoding pickle\s+/) } + end + describe 'a feature with no name' do define_feature <<-FEATURE Feature: