Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove code for 1.8 in test (for Travis) #577

Merged
merged 1 commit into from
Apr 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
242 changes: 120 additions & 122 deletions test/test_i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,151 +6,149 @@
class I18nTest < Test::Unit::TestCase
include ReVIEW

if RUBY_VERSION !~ /^1.8/ ## to avoid Travis error :-(
def test_load_locale_yml
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "locale.yml")
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
I18n.setup
assert_equal "bar", I18n.t("foo")
end
def test_load_locale_yml
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "locale.yml")
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
I18n.setup
assert_equal "bar", I18n.t("foo")
end
end
end

def test_load_locale_yaml
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "locale.yaml")
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
assert_raise ReVIEW::ConfigError do
I18n.setup
end
def test_load_locale_yaml
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "locale.yaml")
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
assert_raise ReVIEW::ConfigError do
I18n.setup
end
end
end
end

def test_load_foo_yaml
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "foo.yml")
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
I18n.setup("ja","foo.yml")
assert_equal "bar", I18n.t("foo")
end
def test_load_foo_yaml
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "foo.yml")
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
I18n.setup("ja","foo.yml")
assert_equal "bar", I18n.t("foo")
end
end
end

def test_update_foo_yaml
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "foo.yml")
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
i18n = ReVIEW::I18n.new("ja")
i18n.update_localefile(File.join(Dir.pwd, "foo.yml"))
assert_equal "bar", i18n.t("foo")
end
def test_update_foo_yaml
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "foo.yml")
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
i18n = ReVIEW::I18n.new("ja")
i18n.update_localefile(File.join(Dir.pwd, "foo.yml"))
assert_equal "bar", i18n.t("foo")
end
end
end

def test_update_foo_yaml_i18nclass
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "foo.yml")
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
I18n.setup("ja", "foo.yml")
assert_equal "bar", I18n.t("foo")
end
def test_update_foo_yaml_i18nclass
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "foo.yml")
File.open(file, "w"){|f| f.write("locale: ja\nfoo: \"bar\"\n")}
I18n.setup("ja", "foo.yml")
assert_equal "bar", I18n.t("foo")
end
end
end

def test_load_locale_yml_i18n
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "locale.yml")
File.open(file, "w"){|f| f.write("ja:\n foo: \"bar\"\nen:\n foo: \"buz\"\n")}
I18n.setup
assert_equal "bar", I18n.t("foo")
assert_equal "図", I18n.t("image")
I18n.setup("en")
assert_equal "buz", I18n.t("foo")
assert_equal "Figure ", I18n.t("image")
end
def test_load_locale_yml_i18n
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "locale.yml")
File.open(file, "w"){|f| f.write("ja:\n foo: \"bar\"\nen:\n foo: \"buz\"\n")}
I18n.setup
assert_equal "bar", I18n.t("foo")
assert_equal "図", I18n.t("image")
I18n.setup("en")
assert_equal "buz", I18n.t("foo")
assert_equal "Figure ", I18n.t("image")
end
end
end

def test_load_locale_invalid_yml
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "locale.yml")
File.open(file, "w"){|f| f.write("local: ja\nfoo: \"bar\"\n")}
assert_raises(ReVIEW::KeyError) do
I18n.setup
end
def test_load_locale_invalid_yml
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "locale.yml")
File.open(file, "w"){|f| f.write("local: ja\nfoo: \"bar\"\n")}
assert_raises(ReVIEW::KeyError) do
I18n.setup
end
end
end
end

def test_custom_format
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "locale.yml")
File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pa章")}
I18n.setup("ja")
assert_equal "第a章", I18n.t("chapter", 1)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pA章")}
I18n.setup("ja")
assert_equal "第B章", I18n.t("chapter", 2)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pAW章")}
I18n.setup("ja")
assert_equal "第B章", I18n.t("chapter", 2)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%paW章")}
I18n.setup("ja")
assert_equal "第b章", I18n.t("chapter", 2)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pR章")}
I18n.setup("ja")
assert_equal "第I章", I18n.t("chapter", 1)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pr章")}
I18n.setup("ja")
assert_equal "第ii章", I18n.t("chapter", 2)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pRW章")}
I18n.setup("ja")
assert_equal "第Ⅻ章", I18n.t("chapter", 12)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pJ章")}
I18n.setup("ja")
assert_equal "第二十七章", I18n.t("chapter", 27)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pdW章")}
I18n.setup("ja")
assert_equal "第1章", I18n.t("chapter", 1)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pdW章")}
I18n.setup("ja")
assert_equal "第27章", I18n.t("chapter", 27)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pDW章")}
I18n.setup("ja")
assert_equal "第1章", I18n.t("chapter", 1)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pDW章")}
I18n.setup("ja")
assert_equal "第27章", I18n.t("chapter", 27)

File.open(file, "w"){|f| f.write("locale: ja\npart: Part %pRW")}
I18n.setup("ja")
assert_equal "Part 0", I18n.t("part", 0)

File.open(file, "w"){|f| f.write("locale: ja\npart: 第%pJ部")}
I18n.setup("ja")
assert_equal "第一部", I18n.t("part", 1)
end
def test_custom_format
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
file = File.join(dir, "locale.yml")
File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pa章")}
I18n.setup("ja")
assert_equal "第a章", I18n.t("chapter", 1)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pA章")}
I18n.setup("ja")
assert_equal "第B章", I18n.t("chapter", 2)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pAW章")}
I18n.setup("ja")
assert_equal "第B章", I18n.t("chapter", 2)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%paW章")}
I18n.setup("ja")
assert_equal "第b章", I18n.t("chapter", 2)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pR章")}
I18n.setup("ja")
assert_equal "第I章", I18n.t("chapter", 1)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pr章")}
I18n.setup("ja")
assert_equal "第ii章", I18n.t("chapter", 2)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pRW章")}
I18n.setup("ja")
assert_equal "第Ⅻ章", I18n.t("chapter", 12)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pJ章")}
I18n.setup("ja")
assert_equal "第二十七章", I18n.t("chapter", 27)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pdW章")}
I18n.setup("ja")
assert_equal "第1章", I18n.t("chapter", 1)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pdW章")}
I18n.setup("ja")
assert_equal "第27章", I18n.t("chapter", 27)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pDW章")}
I18n.setup("ja")
assert_equal "第1章", I18n.t("chapter", 1)

File.open(file, "w"){|f| f.write("locale: ja\nchapter: 第%pDW章")}
I18n.setup("ja")
assert_equal "第27章", I18n.t("chapter", 27)

File.open(file, "w"){|f| f.write("locale: ja\npart: Part %pRW")}
I18n.setup("ja")
assert_equal "Part 0", I18n.t("part", 0)

File.open(file, "w"){|f| f.write("locale: ja\npart: 第%pJ部")}
I18n.setup("ja")
assert_equal "第一部", I18n.t("part", 1)
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions test/test_pdfmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@ def test_gettemplate
end

def test_gettemplate_with_backmatter
if RUBY_VERSION =~ /^1.8/
$stderr.puts "skip test_gettemplate_with_backmatter (for travis error)"
return
end
@config.merge!({
"backcover"=>"backcover.html",
"profile"=>"profile.html",
Expand Down