Sha256: 11aa54f340e203b7ec7e9d766920fdad235a0a9659f6188bb78fdb3d8daec588

Contents?: true

Size: 846 Bytes

Versions: 28

Compression:

Stored size: 846 Bytes

Contents

require "stringio"
module DeepTest
  module ObjectExtension
    def capture_stdout
      old_stdout, $stdout = $stdout, StringIO.new
      yield
      $stdout.string
    ensure
      $stdout = old_stdout if old_stdout
    end

    def capture_stderr
      old_stderr, $stderr = $stderr, StringIO.new
      yield
      $stderr.string
    ensure
      $stderr = old_stderr if old_stderr
    end
    
    def retrying(description = nil, times = 5)
      i = 0
      loop do
        begin
          return yield
        rescue => e
          i += 1
          print "#{description} received exception #{e}. "
          if i < times
            puts "Retrying..."
            sleep 0.5
          else
            puts "Aborting."
            raise e
          end
        end
      end
    end
  end
end
Object.send :include, DeepTest::ObjectExtension

Version data entries

28 entries across 28 versions & 5 rubygems

Version Path
jason-o-matic-deep_test-1.2.2.1 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.10 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.11 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.12 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.13 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.14 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.2 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.3 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.4 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.5 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.6 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.7 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.8 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.9 lib/deep_test/extensions/object_extension.rb
jperkins-deep_test-1.2.2 lib/deep_test/extensions/object_extension.rb
deep_test_pre-2.0 lib/deep_test/extensions/object_extension.rb
jason-o-matic-deep_test-1.2.2.15 lib/deep_test/extensions/object_extension.rb
jstorimer-deep-test-2.0.0 lib/deep_test/extensions/object_extension.rb
jstorimer-deep-test-1.4.0 lib/deep_test/extensions/object_extension.rb
jstorimer-deep-test-1.3.0 lib/deep_test/extensions/object_extension.rb