spec/jldrill/stories/UserAddsVocabToQuiz_story.rb in jldrill-0.5.1.7 vs spec/jldrill/stories/UserAddsVocabToQuiz_story.rb in jldrill-0.6.0.1
- old
+ new
@@ -1,5 +1,6 @@
+# encoding: utf-8
require 'jldrill/contexts/AddNewVocabularyContext'
require 'jldrill/views/gtk/QuizStatusView'
require 'jldrill/views/gtk/VocabularyView'
require 'jldrill/views/gtk/MainWindowView'
require 'jldrill/views/gtk/CommandView'
@@ -216,8 +217,38 @@
Story.context.search(nil, nil).should be_empty
Story.context.search(nil, "").should be_empty
# It should find entries
Story.context.search(nil, "あめ").should have_at_least(1).item
+ end
+
+ it "can load the and search the Chinese dictionary from this context" do
+ Story.start
+ Story.mainContext.addNewVocabulary
+ # The dictionary isn't loaded yet.
+ Story.context.dictionaryLoaded?.should be(false)
+
+ # Searching should find nothing
+ Story.context.search("一生", nil).should be_empty
+
+ # Override with the small test dictionary
+ Story.useChineseTestDictionary
+ Story.mainContext.quiz.options.language.should eql("Chinese")
+
+ # Load the dictionary
+ Story.context.loadDictionary
+ Story.context.dictionaryLoaded?.should be(true)
+
+ # Searching for nil or empty string should find nothing
+ Story.context.search(nil, nil).should be_empty
+ Story.context.search(nil, "").should be_empty
+
+ # It should find entries
+ entries = Story.context.search("一生", nil)
+ entries.size.should eql(2)
+
+ entries[0].toVocab.kanji.should eql("一生")
+ entries[0].toVocab.reading.should eql("yi1 sheng1")
+ entries[0].toVocab.definitions.to_s.should eql("all one's life, throughout one's life")
end
end
end