diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-05-26 13:47:57 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-05-28 10:44:10 +0100 |
commit | ca84f7b51f9c95fea57aca9ab5b1d911b467831f (patch) | |
tree | bd2dfc03efad6228e2767071fcd0d36ae14ab009 /spec/lib | |
parent | cf9f0b6096872557005bf92433ea3499697713f0 (diff) |
Make sure spelling corrections are encoded as UTF-8
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/acts_as_xapian_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/lib/acts_as_xapian_spec.rb b/spec/lib/acts_as_xapian_spec.rb index 24ca47452..d411bf856 100644 --- a/spec/lib/acts_as_xapian_spec.rb +++ b/spec/lib/acts_as_xapian_spec.rb @@ -72,4 +72,33 @@ describe ActsAsXapian::Search do end end + describe :spelling_correction do + + before :all do + @alice = FactoryGirl.create(:public_body, :name => 'alice') + @bob = FactoryGirl.create(:public_body, :name => 'bôbby') + ActsAsXapian.update_index + end + + it 'returns a UTF-8 encoded string' do + s = ActsAsXapian::Search.new([PublicBody], "alece", :limit => 100) + s.spelling_correction.should == "alice" + if s.spelling_correction.respond_to? :encoding + s.spelling_correction.encoding.to_s.should == 'UTF-8' + end + end + + it 'handles non-ASCII characters' do + s = ActsAsXapian::Search.new([PublicBody], "bobby", :limit => 100) + s.spelling_correction.should == "bôbby" + end + + after :all do + @alice.destroy + @bob.destroy + ActsAsXapian.update_index + end + + end + end
\ No newline at end of file |