Sha256: bf2c13b6a985bed560a3f37758376e9bd80136a91a7a599fb1ad0e0215c34b1e

Contents?: true

Size: 884 Bytes

Versions: 52

Compression:

Stored size: 884 Bytes

Contents

module ActiveSupport
  module Testing
    module Stream #:nodoc:
      private

      def silence_stream(stream)
        old_stream = stream.dup
        stream.reopen(IO::NULL)
        stream.sync = true
        yield
      ensure
        stream.reopen(old_stream)
        old_stream.close
      end

      def quietly
        silence_stream(STDOUT) do
          silence_stream(STDERR) do
            yield
          end
        end
      end

      def capture(stream)
        stream = stream.to_s
        captured_stream = Tempfile.new(stream)
        stream_io = eval("$#{stream}")
        origin_stream = stream_io.dup
        stream_io.reopen(captured_stream)

        yield

        stream_io.rewind
        return captured_stream.read
      ensure
        captured_stream.close
        captured_stream.unlink
        stream_io.reopen(origin_stream)
      end
    end
  end
end

Version data entries

52 entries across 50 versions & 8 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/activesupport-5.0.7.1/lib/active_support/testing/stream.rb
activesupport-5.0.7.2 lib/active_support/testing/stream.rb
activesupport-5.0.7.1 lib/active_support/testing/stream.rb
activesupport-5.0.7 lib/active_support/testing/stream.rb
activesupport-5.0.6 lib/active_support/testing/stream.rb
activesupport-5.0.6.rc1 lib/active_support/testing/stream.rb
activesupport-5.0.5 lib/active_support/testing/stream.rb
activesupport-5.0.5.rc2 lib/active_support/testing/stream.rb
activesupport-5.0.5.rc1 lib/active_support/testing/stream.rb
tdiary-5.0.5 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/testing/stream.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/activesupport-5.0.2/lib/active_support/testing/stream.rb
activesupport-5.0.4 lib/active_support/testing/stream.rb
activesupport-5.0.4.rc1 lib/active_support/testing/stream.rb
activesupport-5.0.3 lib/active_support/testing/stream.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activesupport-5.0.2/lib/active_support/testing/stream.rb
lazy_record-0.2.1 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/testing/stream.rb
lazy_record-0.2.0 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/testing/stream.rb
lazy_record-0.1.9 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/testing/stream.rb
lazy_record-0.1.8 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/testing/stream.rb
lazy_record-0.1.7 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/testing/stream.rb