spec/support/helpers.rb in travis-1.11.1 vs spec/support/helpers.rb in travis-1.12.0

- old
+ new

@@ -1,16 +1,21 @@ +# frozen_string_literal: true + require 'spec_helper' require 'stringio' require 'ostruct' module Helpers attr_reader :last_run def capture - _stdout, $stdout = $stdout, StringIO.new - _stderr, $stderr = $stderr, StringIO.new - _stdin, $stdin = $stdin, StringIO.new + _stdout = $stdout + $stdout = StringIO.new + _stderr = $stderr + $stderr = StringIO.new + _stdin = $stdin + $stdin = StringIO.new yield capture_result(true) rescue SystemExit => e capture_result(e.success?) ensure @@ -28,18 +33,18 @@ Travis::CLI.run(*args) end end def stderr - last_run.err if last_run + last_run&.err end def stdout - last_run.out if last_run + last_run&.out end private - def capture_result(success) - @last_run = OpenStruct.new(:out => $stdout.string, :err => $stderr.string, :success? => success) - end + def capture_result(success) + @last_run = OpenStruct.new(out: $stdout.string, err: $stderr.string, success?: success) + end end