blob: a405a5cd9d90c82433a2b824ca753c6146914c69 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
require 'test/unit'
require 'fileutils'
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib"
# For this while, let's load all generators by hand
require 'generator/generators/app'
class GeneratorTestCase < Test::Unit::TestCase
include FileUtils
def destination_root
@destinartion_root ||= File.expand_path("#{File.dirname(__FILE__)}/../fixtures/tmp")
end
def setup
mkdir_p(destination_root)
rm_rf(destination_root)
end
def test_truth
# don't complain, test/unit
end
def capture(stream)
begin
stream = stream.to_s
eval "$#{stream} = StringIO.new"
yield
result = eval("$#{stream}").string
ensure
eval("$#{stream} = #{stream.upcase}")
end
result
end
alias :silence :capture
def assert_file(relative, content=nil)
absolute = File.join(destination_root, relative)
assert File.exists?(absolute)
case content
when String
assert_equal content, File.read(absolute)
when Regexp
assert_match content, File.read(absolute)
end
end
end
|