diff options
Diffstat (limited to 'railties/test/generator/generator_test_helper.rb')
-rw-r--r-- | railties/test/generator/generator_test_helper.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/railties/test/generator/generator_test_helper.rb b/railties/test/generator/generator_test_helper.rb new file mode 100644 index 0000000000..251a7868bc --- /dev/null +++ b/railties/test/generator/generator_test_helper.rb @@ -0,0 +1,38 @@ +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 + "#{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 +end |