I am attempting to programmatically run a series of Rspec tests and capture the output of each.
What I have so far is this:
RSpec.configure do |config|
config.formatter = :json
end
out = StringIO.new
err = StringIO.new
RSpec::Core::Runner.run([file], err, out)
This does run the given file correctly, and in the terminal that I run this script from I see the JSON output that I expect... but since I'm giving the runner a StringIO stream, I would expect it to write the JSON output to that instead of stdout. In this case, the out stream is always empty.
Anyone have any idea what I'm doing wrong?
$stdoutto a file instead. If that helps stackoverflow.com/questions/26894443/…$stdout = StringIO.new, but I still get the output on the screen and there's nothing in $stdout, it's a blank StringIO object.runfunction returns 0 on success and 1 on failure. Still no idea why the output stream doesn't seem to work.