null+****@clear*****
null+****@clear*****
Wed Jan 18 16:39:48 JST 2012
SUZUKI Miho 2012-01-18 16:39:48 +0900 (Wed, 18 Jan 2012) New Revision: e8f6ced6a5ed390e29a6f3143b75ec3b33aa6ff8 Merged 70d535b: Merge pull request #18 from logaling/improve-checking-duplicate Log: [#12] improve specs - move #update's specs from glossary_spec to command_spec -remove empty context Modified files: spec/logaling/command_spec.rb spec/logaling/glossary_spec.rb Modified: spec/logaling/command_spec.rb (+21 -16) =================================================================== --- spec/logaling/command_spec.rb 2012-01-12 11:52:39 +0900 (726fcf8) +++ spec/logaling/command_spec.rb 2012-01-18 16:39:48 +0900 (013df95) @@ -293,35 +293,40 @@ describe Logaling::Command do describe "#update" do before do + FileUtils.remove_entry_secure(File.join(LOGALING_HOME, "db", "index_at"), true) command.new('spec', 'en', 'ja') command.add("spec", "テスト", "備考") end - context "not given source-term option" do - # should show err - end - - context "not given target-term option" do - #should show err - end + context "with arguments except note" do + before do + command.update("spec", "テスト", "スペック") + @yaml = YAML::load_file(glossary_path).find{|h| h["source_term"] == "spec" } + end - context "not given new-target-term option" do - #should show err + it "term's target_term should be updated" do + @yaml.should == {"source_term"=>"spec", "target_term"=>"スペック", "note"=>"備考"} + end end - context "with arguments except note" do + context 'with exisiting bilingual pair and note' do before do - command.update("spec", "テスト", "スペック") + @stdout = capture(:stdout) { command.update("spec", "テスト", "テスト", "備考") } end - subject { YAML::load_file(glossary_path).find{|h| h["source_term"] == "spec" }} + it 'should show error message' do + @stdout.should include "already exists" + end + end - it "term's target_term should be updated" do - subject["target_term"].should == "スペック" + context 'with existing bilingual pair and different note' do + before do + command.update("spec", "テスト", "テスト", "備考だけ書き換え") + @yaml = YAML::load_file(glossary_path).find{|h| h["source_term"] == "spec" } end - it "term's note should not be updated" do - subject["note"].should == "備考" + it "should update note" do + @yaml.should == {"source_term"=>"spec", "target_term"=>"テスト", "note"=>"備考だけ書き換え"} end end end Modified: spec/logaling/glossary_spec.rb (+0 -12) =================================================================== --- spec/logaling/glossary_spec.rb 2012-01-12 11:52:39 +0900 (0362999) +++ spec/logaling/glossary_spec.rb 2012-01-18 16:39:48 +0900 (8739096) @@ -84,18 +84,6 @@ module Logaling -> { glossary.update("user", "ユーザ", "ユーザ", "") }.should raise_error(Logaling::TermError) } end - - context 'with note arguments show exisiting bilingual pair and note' do - it { - -> { glossary.update("user", "ユーザ", "ユーザ", "ユーザーではない") }.should raise_error(Logaling::TermError) - } - end - - context 'with note arguments show existing bilingual pair and different note' do - it { - -> { glossary.update("user", "ユーザ", "ユーザ", "最後の音引きはいらない") }.should_not raise_error(Logaling::TermError) - } - end end describe '#delete' do