aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib/acts_as_xapian_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/acts_as_xapian_spec.rb')
-rw-r--r--spec/lib/acts_as_xapian_spec.rb29
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