spec/converterbase_spec.rb in narou-2.1.1.pre.test1 vs spec/converterbase_spec.rb in narou-2.2.0
- old
+ new
@@ -1,15 +1,19 @@
# -*- Encoding: utf-8 -*-
#
# Copyright 2013 whiteleaf. All rights reserved.
#
+require_relative "../lib/inspector"
+require_relative "../lib/novelsetting"
require_relative "../lib/converterbase"
describe ConverterBase do
before do
- @converter = ConverterBase.new(nil, nil, nil)
+ novelsetting = NovelSetting.new("", true)
+ inspector = Inspector.new(novelsetting)
+ @converter = ConverterBase.new(novelsetting, inspector, nil)
@converter.instance_variable_set(:@text_type, "textfile")
end
context "#erase_comments_block" do
context "コメントブロックが存在した場合" do
@@ -57,9 +61,32 @@
hijklmn
-------------------------------------------------
opqrstu
EOS
expect(@converter.erase_comments_block(text)).to eq text
+ end
+ end
+
+ context "#modify_kana_ni_to_kanji_ni" do
+ describe "ニ(カタカナ)の前後1文字がカタカナの場合" do
+ it "カタカナのまま" do
+ expect(@converter.modify_kana_ni_to_kanji_ni("イチニサン")). to eq "イチニサン"
+ expect(@converter.modify_kana_ni_to_kanji_ni("ニーサン")). to eq "ニーサン"
+ end
+ end
+
+ describe "ニ(カタカナ)の前後1文字がカタカナではなく、さらにその前後がカタカナの場合" do
+ it "カタカナのまま" do
+ expect(@converter.modify_kana_ni_to_kanji_ni("イチ、ニ、サン")). to eq "イチ、ニ、サン"
+ expect(@converter.modify_kana_ni_to_kanji_ni("『ニ、ニンゲンの――』")). to eq "『ニ、ニンゲンの――』"
+ expect(@converter.modify_kana_ni_to_kanji_ni("ニ、ニンゲン")). to eq "ニ、ニンゲン"
+ end
+ end
+
+ describe "ニ(カタカナ)の前後1文字がカタカナではなく、さらにその前後がカタカナではない場合" do
+ it "漢字の二に修正する" do
+ expect(@converter.modify_kana_ni_to_kanji_ni("価格はニ千万円")). to eq "価格は二千万円"
+ end
end
end
end