bundle-new/spec/support/streams.rb

14 lines
286 B
Ruby
Raw Normal View History

2019-10-06 15:45:34 +00:00
require 'stringio'
def capture(*streams)
streams.map! { |stream| stream.to_s }
begin
result = StringIO.new
streams.each { |stream| eval "$#{stream} = result" }
yield
ensure
streams.each { |stream| eval("$#{stream} = #{stream.upcase}") }
end
result.string
end