null+****@clear*****
null+****@clear*****
Wed Jan 18 18:11:15 JST 2012
SUZUKI Miho 2012-01-18 18:11:15 +0900 (Wed, 18 Jan 2012) New Revision: 364c97a6fa12df331bf61b359be9b2c578481ca7 Log: [#12] improve to enable to delete the note Modified files: lib/logaling/glossary.rb spec/logaling/glossary_spec.rb Modified: lib/logaling/glossary.rb (+3 -1) =================================================================== --- lib/logaling/glossary.rb 2012-01-18 16:39:48 +0900 (e1e9108) +++ lib/logaling/glossary.rb 2012-01-18 18:11:15 +0900 (d2f1ddb) @@ -130,7 +130,9 @@ module Logaling end def rebuild_term(current, source_term, target_term, note) - note = current['note'] if note.nil? || note == "" + if current['target_term'] != target_term && (note.nil? || note == "") + note = current['note'] + end target_term = current['target_term'] if target_term == "" build_term(source_term, target_term, note) end Modified: spec/logaling/glossary_spec.rb (+13 -6) =================================================================== --- spec/logaling/glossary_spec.rb 2012-01-18 16:39:48 +0900 (8739096) +++ spec/logaling/glossary_spec.rb 2012-01-18 18:11:15 +0900 (e0d36f6) @@ -67,22 +67,29 @@ module Logaling } end - context 'with source-term arguments show not existing bilingual pair' do + context 'with source-term show not existing bilingual pair' do it { -> { glossary.update("use", "ユーザ", "ユーザー", "やっぱりユーザー") }.should raise_error(Logaling::TermError) } end - context 'with target-term arguments show not existing bilingual pair' do + context 'with target-term show not existing bilingual pair' do it { -> { glossary.update("user", "ユー", "ユーザー", "やっぱりユーザー") }.should raise_error(Logaling::TermError) } end - context 'with note arguments show exisiting bilingual pair' do - it { - -> { glossary.update("user", "ユーザ", "ユーザ", "") }.should raise_error(Logaling::TermError) - } + context 'with same target-term and empty note' do + before do + glossary.update("user", "ユーザ", "ユーザ", "") + end + + it 'should clear note' do + yaml = YAML::load_file(glossary_path) + term = yaml.index({"source_term"=>"user", "target_term"=>"ユーザ", "note"=>""}) + term.should_not be_nil + end + end end