summaryrefslogtreecommitdiff
path: root/test/test-main.rb
diff options
context:
space:
mode:
authormakoto kuwata <kwa@kuwata-lab.com>2009-07-15 18:49:34 +0900
committermakoto kuwata <kwa@kuwata-lab.com>2009-07-15 18:49:34 +0900
commitdd9c9ae791bcd086af414c964a1cc7c59be5d8c0 (patch)
tree1940234c992b9d8ee80ca2d3476c2e30a54645ea /test/test-main.rb
parent74015d82a8a505f43c0c2beb6f7befb9a35e7d87 (diff)
downloaderubis-dd9c9ae791bcd086af414c964a1cc7c59be5d8c0.tar.gz
[bugfix] 'main.rb' to 'erubis -z' prints 'Syntax OK' correctly
Diffstat (limited to 'test/test-main.rb')
-rw-r--r--test/test-main.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/test-main.rb b/test/test-main.rb
index 5db3f52..5fe62ac 100644
--- a/test/test-main.rb
+++ b/test/test-main.rb
@@ -201,11 +201,35 @@ END
end
+ def _with_dummy_file
+ bindir = File.join(File.dirname(File.dirname(__FILE__)), 'bin')
+ env_path = ENV['PATH']
+ env__ = ENV['_']
+ begin
+ ENV['PATH'] = bindir + File::PATH_SEPARATOR + ENV['PATH']
+ ENV['_'] = 'erubis'
+ Tempfile.open(self.name.gsub(/[^\w]/,'_')) do |f|
+ f.write(INPUT)
+ f.flush
+ yield(f.path)
+ end
+ ensure
+ ENV['PATH'] = env_path
+ ENV['_'] = env__ if env__
+ end
+ end
+
+
def test_syntax1 # -z (syntax ok)
@input = INPUT
@expected = "Syntax OK\n"
@options = '-z'
_test()
+ #
+ _with_dummy_file do |filepath|
+ actual = `erubis #{@options} #{filepath}`
+ assert_equal @expected, actual
+ end
end