spec/dictionary_spec.rb in ffi-hunspell-0.2.6 vs spec/dictionary_spec.rb in ffi-hunspell-0.3.0
- old
+ new
@@ -33,18 +33,26 @@
dict = subject.open(lang)
dict.close
dict.should be_closed
end
+
+ context "when given an unknown dictionary name" do
+ it "should raise an ArgumentError" do
+ lambda {
+ subject.open('foo')
+ }.should raise_error(ArgumentError)
+ end
+ end
end
subject { described_class.new(affix_path,dic_path) }
after(:all) { subject.close }
it "should provide the encoding of the dictionary files" do
- subject.encoding.should_not be_empty
+ subject.encoding.should == Encoding::ISO_8859_1
end
it "should check if a word is valid" do
subject.should be_valid('dog')
subject.should_not be_valid('dxg')
@@ -53,25 +61,37 @@
describe "#stem" do
it "should find the stems of a word" do
subject.stem('fishing').should == %w[fishing fish]
end
+ it "should force_encode all strings" do
+ subject.suggest('fishing').all? { |string|
+ string.encoding == subject.encoding
+ }.should be_true
+ end
+
context "when there are no stems" do
it "should return []" do
subject.stem("zzzzzzz").should == []
end
end
end
describe "#suggest" do
it "should suggest alternate spellings for words" do
- subject.suggest('arbitrage').should == %w[
- arbitrage
- arbitrages
- arbitrager
- arbitraged
- arbitrate
- ]
+ subject.suggest('arbitrage').should include(*[
+ 'arbitrage',
+ 'arbitrages',
+ 'arbitrager',
+ 'arbitraged',
+ 'arbitrate'
+ ])
+ end
+
+ it "should force_encode all strings" do
+ subject.suggest('arbitrage').all? { |string|
+ string.encoding == subject.encoding
+ }.should be_true
end
context "when there are no suggestions" do
it "should return []" do
subject.suggest("________").should == []