Skip to content

Commit

Permalink
Add test for handling captured output encodings in junit
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAb committed Jan 14, 2018
1 parent 33b4a4a commit b94f329
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions spec/cucumber/formatter/junit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 encoding 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:
Expand Down

0 comments on commit b94f329

Please sign in to comment.