diff options
author | makoto kuwata <kwa@kuwata-lab.com> | 2009-02-07 08:24:36 +0000 |
---|---|---|
committer | makoto kuwata <kwa@kuwata-lab.com> | 2009-02-07 08:24:36 +0000 |
commit | 694d19941e8e52f290f3cb5e6c2afbffba796d5c (patch) | |
tree | b1ada86a7290eb80d68400e1e4337624e2475418 | |
parent | acfea9521349f0b7c22a1032e7afd9e45961701a (diff) | |
download | erubis-694d19941e8e52f290f3cb5e6c2afbffba796d5c.tar.gz |
- [change] change '#!/usr/bin/ruby' to '#!/usr/bin/env ruby' in 'bin/erubis'
- [bugfix] change 'optchar.chr' to 'optchar' in 'main.rb'.
-rw-r--r-- | ChangeLog.txt | 7 | ||||
-rwxr-xr-x | bin/erubis | 2 | ||||
-rw-r--r-- | lib/erubis/main.rb | 6 | ||||
-rw-r--r-- | test/test-main.rb | 24 |
4 files changed, 33 insertions, 6 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index b775cb1..b70e4ec 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,8 +1,11 @@ - l.=document: ChangeLog -.# -*- coding: utf-8 -*- +.=document: ChangeLog .?lastupdate: $Date$ .?version: $Rev$ +: Rev.121 (2009-02-07) + .- [change] change '#!/usr/bin/ruby' to '#!/usr/bin/env ruby' in 'bin/erubis' + .- [bugfix] change 'optchar.chr' to 'optchar' in 'main.rb'. + : Rev.120 (2008-06-13) .- [update] ReleasNote, CHANGES @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#!/usr/bin/env ruby ### ### $Rev$ diff --git a/lib/erubis/main.rb b/lib/erubis/main.rb index 22cdfbd..58084d8 100644 --- a/lib/erubis/main.rb +++ b/lib/erubis/main.rb @@ -326,7 +326,7 @@ module Erubis elsif arg_required.include?(optchar) arg = optstr.empty? ? argv.shift : optstr unless arg - mesg = "-#{optchar.chr}: #{@option_args[optchar]} required." + mesg = "-#{optchar}: #{@option_args[optchar]} required." raise CommandOptionError.new(mesg) end options[optchar] = arg @@ -336,7 +336,7 @@ module Erubis options[optchar] = arg optstr = nil else - raise CommandOptionError.new("-#{optchar.chr}: unknown option.") + raise CommandOptionError.new("-#{optchar}: unknown option.") end end end @@ -399,7 +399,7 @@ module Erubis enhancers << Erubis.const_get("#{shortname}Enhancer") end rescue NameError - raise CommandOptionError.new("#{shortname}: no such Enhancer (try '-E' to show all enhancers).") + raise CommandOptionError.new("#{shortname}: no such Enhancer (try '-h' to show all enhancers).") end return enhancers end diff --git a/test/test-main.rb b/test/test-main.rb index 50cf3ad..dab8006 100644 --- a/test/test-main.rb +++ b/test/test-main.rb @@ -617,6 +617,30 @@ END end + def test_invalid_option # -1 (invalid option) + @input = INPUT + @options = '-1' + ex = assert_raise(Erubis::CommandOptionError) { _test() } + assert_equal("-1: unknown option.", ex.message) + end + + + def test_invalid_enhancer # -E hoge + @options = '-E hoge' + errmsg = "hoge: no such Enhancer (try '-h' to show all enhancers)." + ex = assert_raise(Erubis::CommandOptionError) { _test() } + assert_equal(errmsg, ex.message) + end + + + def test_invalid_lang # -l hoge + @options = '-l hoge' + errmsg = "-l hoge: invalid language name (class Erubis::Ehoge not found)." + ex = assert_raise(Erubis::CommandOptionError) { _test() } + assert_equal(errmsg, ex.message) + end + + def test_pi1 # --pi -x @input = PI_INPUT @expected = PI_SRC |