[logaling-commit] logaling/logaling-command [master] [#23331325] add spec

Back to archive index

null+****@clear***** null+****@clear*****
Wed Jan 25 18:08:09 JST 2012


SUZUKI Miho	2012-01-25 18:08:09 +0900 (Wed, 25 Jan 2012)

  New Revision: 7b91b18b3dffa7cc9fb510dac830a7d98b26614c

  Merged 2152f8c: Merge pull request #25 from logaling/improve-list-command

  Log:
    [#23331325] add spec

  Modified files:
    lib/logaling/command.rb
    spec/logaling/command_spec.rb

  Modified: lib/logaling/command.rb (+2 -2)
===================================================================
--- lib/logaling/command.rb    2012-01-25 17:23:51 +0900 (b32025b)
+++ lib/logaling/command.rb    2012-01-25 18:08:09 +0900 (57af030)
@@ -204,10 +204,10 @@ class Logaling::Command < Thor
       "target-language" => "input target-language code '-T <target-language code>'"
     }
     config = load_config_and_merge_options(required_options)
-    run_pager
     repository.index
     terms = repository.show(config["glossary"], config["source-language"], config["target-language"])
     unless terms.empty?
+      run_pager
       max_str_size = terms.map{|term| term[:source_term].size}.sort.last
       terms.each do |term|
         target_string = "#{term[:target_term]}"
@@ -224,10 +224,10 @@ class Logaling::Command < Thor
 
   desc 'list', 'Show glossary list.'
   def list
-    run_pager
     repository.index
     glossaries = repository.list
     unless glossaries.empty?
+      run_pager
       glossaries.each do |glossary|
         printf("  %s\n", glossary)
       end

  Modified: spec/logaling/command_spec.rb (+34 -0)
===================================================================
--- spec/logaling/command_spec.rb    2012-01-25 17:23:51 +0900 (79d2af2)
+++ spec/logaling/command_spec.rb    2012-01-25 18:08:09 +0900 (5aed829)
@@ -22,6 +22,7 @@ describe Logaling::Command do
   let(:command) { Logaling::Command.new([], base_options) }
   let(:glossary_path) { Logaling::Glossary.build_path('spec', 'en', 'ja') }
   let(:target_project_path) { File.join(LOGALING_HOME, "projects", "spec") }
+  let(:repository) { Logaling::Repository.new(LOGALING_HOME) }
 
   before do
     FileUtils.remove_entry_secure(Logaling::Command::LOGALING_CONFIG, true)
@@ -30,6 +31,7 @@ describe Logaling::Command do
 
   describe '#new' do
     before do
+      sleep(1)
       @project_counts = Dir[File.join(LOGALING_HOME, "projects", "*")].size
     end
 
@@ -80,6 +82,7 @@ describe Logaling::Command do
 
   describe '#register' do
     before do
+      sleep(1)
       @project_counts = Dir[File.join(LOGALING_HOME, "projects", "*")].size
     end
 
@@ -117,6 +120,7 @@ describe Logaling::Command do
 
   describe '#unregister' do
     before do
+      sleep(1)
       @project_counts = Dir[File.join(LOGALING_HOME, "projects", "*")].size
     end
 
@@ -183,6 +187,7 @@ describe Logaling::Command do
 
     context 'with argument "target-language"' do
       before do
+        sleep(1)
         command.new('spec', 'en')
         command.config("target-language", "fr")
       end
@@ -224,6 +229,7 @@ describe Logaling::Command do
 
   describe '#add' do
     before do
+      sleep(1)
       command.new('spec', 'en', 'ja')
     end
 
@@ -417,6 +423,7 @@ describe Logaling::Command do
   describe "#show" do
     let(:csv_path) { File.join(File.dirname(glossary_path), "spec.ja.en.csv") }
     before do
+      sleep(1)
       command.new('spec', 'en', 'ja')
       command.add("spec", "スペック", "備考")
       command.add("spec-test", "スペックてすと", "備考")
@@ -457,6 +464,33 @@ describe Logaling::Command do
     end
   end
 
+  describe '#list' do
+    context 'when some glossaries are registered' do
+      before do
+        sleep(1)
+        command.new('spec', 'en', 'ja')
+        @stdout = capture(:stdout) {command.list}
+      end
+
+      it 'should list glossaries' do
+        @stdout.should include "spec"
+      end
+    end
+    #unregisterしたらglossaryの一覽に入らないこと
+    context 'when a glossary is unregistered' do
+      before do
+        sleep(1)
+        command.new('spec', 'en', 'ja')
+        repository.unregister('spec')
+        @stdout = capture(:stdout) {command.list}
+      end
+
+      it 'should not include unregistered glossary' do
+        @stdout.should_not include "spec"
+      end
+    end
+  end
+
   after do
     FileUtils.remove_entry_secure(Logaling::Command::LOGALING_CONFIG, true)
     FileUtils.remove_entry_secure(File.join(LOGALING_HOME, 'projects', 'spec'), true)




More information about the logaling-commit mailing list
Back to archive index