Skip to content

Commit

Permalink
fix: send output messages to the correct stream when using the XML fo…
Browse files Browse the repository at this point in the history
…rmatter
  • Loading branch information
bethesque committed Jan 22, 2020
1 parent aa8ea5f commit e768a33
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/pact/provider/pact_spec_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,12 @@ def configure_output

output = options[:out] || Pact.configuration.output_stream
if options[:format]
if options[:format] == 'json'
# To avoid mixing JSON and logging, the output_stream will be set to the error_stream
# in the pact-provider-verifier.
# Send JSON to a file if configured, or straight to $stdout
::RSpec.configuration.add_formatter Pact::Provider::RSpec::JsonFormatter, options[:out] || $stdout
else
::RSpec.configuration.add_formatter options[:format], output
end
formatter = options[:format] == 'json' ? Pact::Provider::RSpec::JsonFormatter : options[:format]
# Send formatted output to $stdout for parsing, unless a file is specified
output = options[:out] || $stdout
::RSpec.configuration.add_formatter formatter, output
# Don't want to mess up the JSON parsing with INFO and DEBUG messages to stdout, so send it to stderr
Pact.configuration.output_stream = Pact.configuration.error_stream if !options[:out]
else
# Sometimes the formatter set in the cli.rb get set with an output of StringIO.. don't know why
formatter_class = Pact::RSpec.formatter_class
Expand Down

0 comments on commit e768a33

Please sign in to comment.