Capture stdout during test_prefix

This commit is contained in:
Max Howell 2009-06-15 01:16:00 +01:00
parent eaad8393fd
commit 02e53d44cb

View File

@ -3,6 +3,7 @@
$:.unshift File.dirname(__FILE__) $:.unshift File.dirname(__FILE__)
require 'test/unit' require 'test/unit'
require 'brewkit' require 'brewkit'
require 'stringio'
class TestFormula <Formula class TestFormula <Formula
def initialize url, md5='nomd5' def initialize url, md5='nomd5'
@ -12,6 +13,13 @@ class TestFormula <Formula
end end
end end
def nostdout
tmp=$stdout
$stdout=StringIO.new
yield
$stdout=tmp
end
class BeerTasting <Test::Unit::TestCase class BeerTasting <Test::Unit::TestCase
def test_version_all_dots def test_version_all_dots
@ -87,11 +95,11 @@ class BeerTasting <Test::Unit::TestCase
url='http://www.methylblue.com/test-0.1.tar.gz' url='http://www.methylblue.com/test-0.1.tar.gz'
md5='d496ea538a21dc4bb8524a8888baf88c' md5='d496ea538a21dc4bb8524a8888baf88c'
nostdout do
TestFormula.new(url, md5).brew do |f| TestFormula.new(url, md5).brew do |f|
prefix=f.prefix assert_equal File.expand_path(f.prefix), ($cellar+f.name+'0.1').to_s
# we test for +/unittest/0.1 because we derive @name from $0 assert_kind_of Pathname, f.prefix
assert_equal File.expand_path(prefix), ($cellar+'test'+'0.1').to_s end
assert_kind_of Pathname, prefix
end end
end end
end end