Sha256: e4aeb6fde61f88b2ac8a6f5f7b0e223d12b6d7c8b7350c77a7540f7ddc899ce9
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
require 'rubygems' require 'tempfile' require 'minitest/autorun' require 'mocha' $:.unshift File.expand_path("../../lib") require 'dante' ## Kernel Extensions require 'stringio' module Kernel # Redirect standard out, standard error and the buffered logger for sprinkle to StringIO # capture_stdout { any_commands; you_want } => "all output from the commands" def capture_stdout return yield if ENV['DEBUG'] # Skip if debug mode out = StringIO.new $stdout = out $stderr = out yield return out.string ensure $stdout = STDOUT $stderr = STDERR end end # Process fixture class TestingProcess attr_reader :tmp_path def initialize(name) @tmp_path = "/tmp/dante-#{name}.log" end # initialize def run_a!(data=nil) @tmp = File.new(@tmp_path, 'w') @tmp.puts("Started") @tmp.puts "Data is: #{data}" if data @tmp.close end # run_a! def run_b!(port=9090) begin @tmp = File.new(@tmp_path, 'w') @tmp.print "Started on #{port}!!" sleep(100) rescue Interrupt @tmp.print "Interrupt!!" exit ensure @tmp.print "Closing!!" @tmp.close end end # run_b! end # TestingProcess
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dante-0.1.2 | test/test_helper.rb |
dante-0.1.1 | test/test_helper.rb |
dante-0.1.0 | test/test_helper.rb |